blob: e75afb3bc68839f83fe619470974ea8a09f4cac2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package prometheus
import (
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v14/internal/middleware/limithandler"
)
// Config contains additional configuration data for prometheus
type Config struct {
GRPCLatencyBuckets []float64 `toml:"grpc_latency_buckets"`
}
// Configure configures latency buckets for prometheus timing histograms
func (c *Config) Configure() {
if len(c.GRPCLatencyBuckets) == 0 {
return
}
log.WithField("latencies", c.GRPCLatencyBuckets).Info("grpc prometheus histograms enabled")
grpc_prometheus.EnableHandlingTimeHistogram(func(histogramOpts *prometheus.HistogramOpts) {
histogramOpts.Buckets = c.GRPCLatencyBuckets
})
grpc_prometheus.EnableClientHandlingTimeHistogram(func(histogramOpts *prometheus.HistogramOpts) {
histogramOpts.Buckets = c.GRPCLatencyBuckets
})
limithandler.EnableAcquireTimeHistogram(c.GRPCLatencyBuckets)
}
|