Use atomic.Uint64 for gateway metrics count instead of mutex (#8615)

This commit is contained in:
Nitish Tiwari
2019-12-07 11:21:52 +05:30
committed by GitHub
parent be0c8b1ec0
commit 24ad59316d
2 changed files with 42 additions and 36 deletions

View File

@@ -290,17 +290,25 @@ func (c *minioCollector) Collect(ch chan<- prometheus.Metric) {
prometheus.CounterValue,
float64(m.GetBytesSent()),
)
for method, count := range m.GetRequests() {
ch <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
prometheus.BuildFQName("gateway", globalGatewayName, "requests"),
"Total number of requests made to AWS S3 by current MinIO S3 Gateway",
[]string{"method"}, nil),
prometheus.CounterValue,
float64(count),
method,
)
}
s := m.GetRequests()
ch <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
prometheus.BuildFQName("gateway", globalGatewayName, "requests"),
"Total number of requests made to AWS S3 by current MinIO S3 Gateway",
[]string{"method"}, nil),
prometheus.CounterValue,
float64(s.Get.Load()),
http.MethodGet,
)
ch <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
prometheus.BuildFQName("gateway", globalGatewayName, "requests"),
"Total number of requests made to AWS S3 by current MinIO S3 Gateway",
[]string{"method"}, nil),
prometheus.CounterValue,
float64(s.Head.Load()),
http.MethodHead,
)
}
}