mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-07 06:03:09 -06:00
Only register prometheus metrics if requested
This commit is contained in:
parent
56b2672f92
commit
1437ac42e3
|
|
@ -28,20 +28,22 @@ func MustCreateCache(maxCost config.DataUnit, enablePrometheus bool) *ristretto.
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
promauto.NewGaugeFunc(prometheus.GaugeOpts{
|
||||
Namespace: "dendrite",
|
||||
Subsystem: "caching_ristretto",
|
||||
Name: "ratio",
|
||||
}, func() float64 {
|
||||
return float64(cache.Metrics.Ratio())
|
||||
})
|
||||
promauto.NewGaugeFunc(prometheus.GaugeOpts{
|
||||
Namespace: "dendrite",
|
||||
Subsystem: "caching_ristretto",
|
||||
Name: "cost",
|
||||
}, func() float64 {
|
||||
return float64(cache.Metrics.CostAdded() - cache.Metrics.CostEvicted())
|
||||
})
|
||||
if enablePrometheus {
|
||||
promauto.NewGaugeFunc(prometheus.GaugeOpts{
|
||||
Namespace: "dendrite",
|
||||
Subsystem: "caching_ristretto",
|
||||
Name: "ratio",
|
||||
}, func() float64 {
|
||||
return float64(cache.Metrics.Ratio())
|
||||
})
|
||||
promauto.NewGaugeFunc(prometheus.GaugeOpts{
|
||||
Namespace: "dendrite",
|
||||
Subsystem: "caching_ristretto",
|
||||
Name: "cost",
|
||||
}, func() float64 {
|
||||
return float64(cache.Metrics.CostAdded() - cache.Metrics.CostEvicted())
|
||||
})
|
||||
}
|
||||
return cache
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue