eolivelli commented on code in PR #4300:
URL: https://github.com/apache/bookkeeper/pull/4300#discussion_r1576507389


##########
stats/bookkeeper-stats-providers/prometheus-metrics-provider/src/main/java/org/apache/bookkeeper/stats/prometheus/ThreadScopedDataSketchesStatsLogger.java:
##########
@@ -96,15 +96,25 @@ private DataSketchesOpStatsLogger getStatsLogger() {
             ThreadRegistry.ThreadPoolThread tpt = ThreadRegistry.get();
             if (tpt == null) {
                 statsLoggers.set(defaultStatsLogger);
-                provider.opStats.put(new ScopeContext(scopeContext.getScope(), 
originalLabels), defaultStatsLogger);
+                DataSketchesOpStatsLogger previous = provider.opStats
+                        .put(new ScopeContext(scopeContext.getScope(), 
originalLabels), defaultStatsLogger);
+                // If we overwrite a logger, metrics will not be collected 
correctly
+                if (previous != null && previous != defaultStatsLogger) {
+                    throw new IllegalStateException("Invalid state. Overwrote 
a stats logger.");
+                }

Review Comment:
   I would add a log line about this case, because we should notice when 
something is using the "default" statslogger, its matrics don't make much sense 
and they won't probably meaningful for administrators.
   So it is fine to not break but we should log a warning



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to