tracker/storage/prometheus.go
Jimmy Zelinskie dab03f52dc storage: share prometheus models
Running of the binary actually caused a panic due to multiple calling of
MustRegister(). This fixes that by sharing models in the storage
package.
2017-06-05 22:07:13 -04:00

45 lines
1.4 KiB
Go

package storage
import "github.com/prometheus/client_golang/prometheus"
func init() {
// Register the metrics.
prometheus.MustRegister(
PromGCDurationMilliseconds,
PromInfohashesCount,
PromSeedersCount,
PromLeechersCount,
)
}
var (
// PromGCDurationMilliseconds is a histogram used by storage to record the
// durations of execution time required for removing expired peers.
PromGCDurationMilliseconds = prometheus.NewHistogram(prometheus.HistogramOpts{
Name: "chihaya_storage_gc_duration_milliseconds",
Help: "The time it takes to perform storage garbage collection",
Buckets: prometheus.ExponentialBuckets(9.375, 2, 10),
})
// PromInfohashesCount is a gauge used to hold the current total amount of
// unique swarms being tracked by a storage.
PromInfohashesCount = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "chihaya_storage_infohashes_count",
Help: "The number of Infohashes tracked",
})
// PromSeedersCount is a gauge used to hold the current total amount of
// unique seeders per swarm.
PromSeedersCount = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "chihaya_storage_seeders_count",
Help: "The number of seeders tracked",
})
// PromLeechersCount is a gauge used to hold the current total amount of
// unique leechers per swarm.
PromLeechersCount = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "chihaya_storage_leechers_count",
Help: "The number of leechers tracked",
})
)