2021-07-06 02:20:38 +02:00
|
|
|
package metrics
|
|
|
|
|
|
|
|
import (
|
2021-10-15 22:26:33 +02:00
|
|
|
"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 (
|
2021-10-15 22:26:33 +02:00
|
|
|
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",
|
|
|
|
})
|
2021-10-15 22:26:33 +02:00
|
|
|
QueryTime = promauto.NewHistogramVec(prometheus.HistogramOpts{
|
2021-07-06 02:20:38 +02:00
|
|
|
Name: "query_time",
|
2021-10-15 22:26:33 +02:00
|
|
|
Help: "Histogram of query times",
|
|
|
|
Buckets: HistogramBuckets,
|
|
|
|
}, []string{"method"})
|
2021-07-06 02:20:38 +02:00
|
|
|
)
|
|
|
|
|