From 57ca96d2c0a1ec666ca9eb5ef6a50256a91a228e Mon Sep 17 00:00:00 2001 From: linhai zhu Date: Thu, 8 Feb 2024 17:24:55 -0800 Subject: [PATCH] do not allocate gauge if cardinality metrics are turned off --- scope_registry.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scope_registry.go b/scope_registry.go index d1481da..fc1b50b 100644 --- a/scope_registry.go +++ b/scope_registry.go @@ -103,7 +103,7 @@ func newScopeRegistryWithShardCount( } r.subscopes[i].s[scopeRegistryKey(root.prefix, root.tags)] = root } - if r.root.cachedReporter != nil { + if r.root.cachedReporter != nil && !omitCardinalityMetrics { r.cachedCounterCardinalityGauge = r.root.cachedReporter.AllocateGauge(r.sanitizedCounterCardinalityName, r.cardinalityMetricsTags) r.cachedGaugeCardinalityGauge = r.root.cachedReporter.AllocateGauge(r.sanitizedGaugeCardinalityName, r.cardinalityMetricsTags) r.cachedHistogramCardinalityGauge = r.root.cachedReporter.AllocateGauge(r.sanitizedHistogramCardinalityName, r.cardinalityMetricsTags)