mirror of
https://github.com/minio/minio.git
synced 2025-02-04 10:26:01 -05:00
fix: Create metrics slice when necessary in getCacheMetrics() (#17711)
This commit is contained in:
parent
2da4bd5f1a
commit
a7fb3a3853
@ -1863,12 +1863,12 @@ func getCacheMetrics() *MetricsGroup {
|
|||||||
cacheInterval: 10 * time.Second,
|
cacheInterval: 10 * time.Second,
|
||||||
}
|
}
|
||||||
mg.RegisterRead(func(ctx context.Context) (metrics []Metric) {
|
mg.RegisterRead(func(ctx context.Context) (metrics []Metric) {
|
||||||
metrics = make([]Metric, 0, 20)
|
|
||||||
cacheObjLayer := newCachedObjectLayerFn()
|
cacheObjLayer := newCachedObjectLayerFn()
|
||||||
// Service not initialized yet
|
// Service not initialized yet
|
||||||
if cacheObjLayer == nil {
|
if cacheObjLayer == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
metrics = make([]Metric, 0, 20)
|
||||||
metrics = append(metrics, Metric{
|
metrics = append(metrics, Metric{
|
||||||
Description: getCacheHitsTotalMD(),
|
Description: getCacheHitsTotalMD(),
|
||||||
Value: float64(cacheObjLayer.CacheStats().getHits()),
|
Value: float64(cacheObjLayer.CacheStats().getHits()),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user