mirror of
https://github.com/minio/minio.git
synced 2025-04-19 02:05:24 -04:00
Suppress metrics with zero values (#19638)
This would reduce the size of data in response of metrics listing. While graphing we can default these metrics with a zero value if not found. Signed-off-by: Shubhendu Ram Tripathi <shubhendu@minio.io>
This commit is contained in:
parent
6bb10a81a6
commit
6579304d8c
@ -232,10 +232,13 @@ func (m *MetricValues) Set(name MetricName, value float64, labels ...string) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
v = make([]metricValue, 0, 1)
|
v = make([]metricValue, 0, 1)
|
||||||
}
|
}
|
||||||
|
// If valid non zero value set the metrics
|
||||||
|
if value > 0 {
|
||||||
m.values[name] = append(v, metricValue{
|
m.values[name] = append(v, metricValue{
|
||||||
Labels: labelMap,
|
Labels: labelMap,
|
||||||
Value: value,
|
Value: value,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetHistogram - sets values for the given MetricName using the provided
|
// SetHistogram - sets values for the given MetricName using the provided
|
||||||
@ -274,8 +277,11 @@ func (m *MetricValues) SetHistogram(name MetricName, hist *prometheus.HistogramV
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
labels = append(labels, extraLabels...)
|
labels = append(labels, extraLabels...)
|
||||||
|
// If valid non zero value set the metrics
|
||||||
|
if metric.Value > 0 {
|
||||||
m.Set(name, metric.Value, labels...)
|
m.Set(name, metric.Value, labels...)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MetricsLoaderFn - represents a function to load metrics from the
|
// MetricsLoaderFn - represents a function to load metrics from the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user