From 5949050b6bc48bcf96150a02371a5ce10d6b61da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C4=8Ctvrtka?= Date: Tue, 2 Jan 2024 09:16:30 +0100 Subject: [PATCH] PMM-12712 Small refactor. --- exporter/sharded_collector.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/exporter/sharded_collector.go b/exporter/sharded_collector.go index e70c7cbdb..00615745c 100644 --- a/exporter/sharded_collector.go +++ b/exporter/sharded_collector.go @@ -55,6 +55,7 @@ func (d *shardedCollector) collect(ch chan<- prometheus.Metric) { client := d.base.client logger := d.base.logger + prefix := "sharded collection chunks" databaseNames, err := client.ListDatabaseNames(d.ctx, bson.D{}) if err != nil { @@ -82,7 +83,6 @@ func (d *shardedCollector) collect(ch chan<- prometheus.Metric) { continue } - prefix := "sharded collection chunks" labels := make(map[string]string) labels["database"] = database labels["collection"] = strings.Replace(rowID, fmt.Sprintf("%s.", database), "", 1) @@ -106,8 +106,7 @@ func (d *shardedCollector) collect(ch chan<- prometheus.Metric) { if chunks, ok = c["nChunks"].(int32); !ok { continue } - m := primitive.M{"count": chunks} - for _, metric := range makeMetrics(prefix, m, labels, d.compatible) { + for _, metric := range makeMetrics(prefix, primitive.M{"count": chunks}, labels, d.compatible) { ch <- metric } }