herald.go/internal/metrics/metrics.go

63 lines
2 KiB
Go
Raw Normal View History

2021-07-06 02:20:38 +02:00
package metrics
import (
"github.com/lbryio/hub/meta"
2021-07-06 02:20:38 +02:00
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
var (
HistogramBuckets = []float64{0.005, 0.025, 0.05, 0.1, 0.25, 0.4, 1, 2, 5, 10, 20, 60, 120, 300}
// These mirror counters from the python code
RequestsCount = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "requests_count",
Help: "Total number of searches",
}, []string{"method"})
SessionCount = promauto.NewGauge(prometheus.GaugeOpts{
Name: "session_count",
Help: "Number of client sessions",
ConstLabels: map[string]string{
"version": meta.Version,
},
})
// These are unique to the go code
2021-07-06 02:20:38 +02:00
PingsCounter = promauto.NewCounter(prometheus.CounterOpts{
Name: "pings",
Help: "Number of pings",
})
ZeroChannelsCounter = promauto.NewCounter(prometheus.CounterOpts{
Name: "zero_channels_counter",
2021-09-21 21:00:08 +02:00
Help: "Number of times zero channels were returned in getUniqueChannels",
2021-07-06 02:20:38 +02:00
})
NoRepostedCounter = promauto.NewCounter(prometheus.CounterOpts{
Name: "no_reposted_counter",
Help: "Number of times zero reposted were returned in getClaimsForRepost",
})
GetUniqueChannelsErrorCounter = promauto.NewCounter(prometheus.CounterOpts{
Name: "get_unique_channels_error_counter",
Help: "Number of errors",
})
JsonErrorCounter = promauto.NewCounter(prometheus.CounterOpts{
Name: "json_error_counter",
Help: "JSON parsing errors",
})
MgetErrorCounter = promauto.NewCounter(prometheus.CounterOpts{
Name: "mget_error_counter",
Help: "Mget errors",
})
SearchErrorCounter = promauto.NewCounter(prometheus.CounterOpts{
Name: "search_error_counter",
Help: "Number of errors",
})
FatalErrorCounter = promauto.NewCounter(prometheus.CounterOpts{
Name: "fatal_error_counter",
Help: "Number of errors",
})
QueryTime = promauto.NewHistogramVec(prometheus.HistogramOpts{
2021-07-06 02:20:38 +02:00
Name: "query_time",
Help: "Histogram of query times",
Buckets: HistogramBuckets,
}, []string{"method"})
2021-07-06 02:20:38 +02:00
)