mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-08 14:43: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 {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
promauto.NewGaugeFunc(prometheus.GaugeOpts{
|
if enablePrometheus {
|
||||||
Namespace: "dendrite",
|
promauto.NewGaugeFunc(prometheus.GaugeOpts{
|
||||||
Subsystem: "caching_ristretto",
|
Namespace: "dendrite",
|
||||||
Name: "ratio",
|
Subsystem: "caching_ristretto",
|
||||||
}, func() float64 {
|
Name: "ratio",
|
||||||
return float64(cache.Metrics.Ratio())
|
}, func() float64 {
|
||||||
})
|
return float64(cache.Metrics.Ratio())
|
||||||
promauto.NewGaugeFunc(prometheus.GaugeOpts{
|
})
|
||||||
Namespace: "dendrite",
|
promauto.NewGaugeFunc(prometheus.GaugeOpts{
|
||||||
Subsystem: "caching_ristretto",
|
Namespace: "dendrite",
|
||||||
Name: "cost",
|
Subsystem: "caching_ristretto",
|
||||||
}, func() float64 {
|
Name: "cost",
|
||||||
return float64(cache.Metrics.CostAdded() - cache.Metrics.CostEvicted())
|
}, func() float64 {
|
||||||
})
|
return float64(cache.Metrics.CostAdded() - cache.Metrics.CostEvicted())
|
||||||
|
})
|
||||||
|
}
|
||||||
return cache
|
return cache
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue