From 9cf7a40b217cf8f30bf9cf867148342eebd8fe78 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Mon, 16 Dec 2024 17:16:43 -0800 Subject: [PATCH] Add a minor log to help debug when Meter is obtained from noops (#2435) --- opentelemetry/src/metrics/noop.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/opentelemetry/src/metrics/noop.rs b/opentelemetry/src/metrics/noop.rs index 80201ad06a..2d74be2805 100644 --- a/opentelemetry/src/metrics/noop.rs +++ b/opentelemetry/src/metrics/noop.rs @@ -5,7 +5,7 @@ //! runtime impact. use crate::{ metrics::{InstrumentProvider, Meter, MeterProvider}, - KeyValue, + otel_debug, KeyValue, }; use std::sync::Arc; @@ -25,7 +25,8 @@ impl NoopMeterProvider { } impl MeterProvider for NoopMeterProvider { - fn meter_with_scope(&self, _scope: crate::InstrumentationScope) -> Meter { + fn meter_with_scope(&self, scope: crate::InstrumentationScope) -> Meter { + otel_debug!(name: "NoopMeterProvider.MeterCreation", meter_name = scope.name(), message = "Meter was obtained from a NoopMeterProvider. No metrics will be recorded. If global::meter_with_scope()/meter() was used, ensure that a valid MeterProvider is set globally before creating Meter."); Meter::new(Arc::new(NoopMeter::new())) } }