From 5da932a7c9c90d603ed699dc20dfdf3eb7a06fbf Mon Sep 17 00:00:00 2001 From: "keisuke.yamashita" <19yamashita15@gmail.com> Date: Thu, 14 Nov 2024 15:39:37 +0100 Subject: [PATCH] Fix diagnostic data merge logic for MongoDB Signed-off-by: keisuke.yamashita <19yamashita15@gmail.com> --- exporter/diagnostic_data_collector.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/exporter/diagnostic_data_collector.go b/exporter/diagnostic_data_collector.go index 57b4b7e9..4daf9a5f 100644 --- a/exporter/diagnostic_data_collector.go +++ b/exporter/diagnostic_data_collector.go @@ -118,8 +118,9 @@ func (d *diagnosticDataCollector) collect(ch chan<- prometheus.Metric) { // MongoDB 8.0 splits the diagnostic data into multiple blocks, so we need to merge them if d.buildInfo.VersionArray[0] >= 8 { //nolint:gomnd - b := bson.M{} - for _, mv := range m { + nm := bson.M{} + for i, mv := range m { + b := bson.M{} block, ok := mv.(bson.M) if !ok { continue @@ -127,8 +128,11 @@ func (d *diagnosticDataCollector) collect(ch chan<- prometheus.Metric) { for k, v := range block { b[k] = v } + + nm[i] = b } - m = b + + m = nm } metrics = makeMetrics("", m, d.topologyInfo.baseLabels(), d.compatibleMode)