From b7276d824ee9a9479fe8d7dc536d1c8edbe2a591 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Wed, 27 Nov 2024 11:45:03 -0800 Subject: [PATCH] Minor Internal logs (#2361) --- examples/self-diagnostics/Cargo.toml | 2 +- opentelemetry-sdk/src/logs/log_emitter.rs | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/examples/self-diagnostics/Cargo.toml b/examples/self-diagnostics/Cargo.toml index 2caea54105..0f32702fe5 100644 --- a/examples/self-diagnostics/Cargo.toml +++ b/examples/self-diagnostics/Cargo.toml @@ -12,4 +12,4 @@ opentelemetry-stdout = { path = "../../opentelemetry-stdout"} tokio = { workspace = true, features = ["full"] } tracing = { workspace = true, features = ["std"]} tracing-core = { workspace = true } -tracing-subscriber = { version = "0.3.18", features = ["env-filter","registry", "std"]} +tracing-subscriber = { workspace = true, features = ["env-filter","registry", "std", "fmt"]} diff --git a/opentelemetry-sdk/src/logs/log_emitter.rs b/opentelemetry-sdk/src/logs/log_emitter.rs index a39152dbfd..efa8c42641 100644 --- a/opentelemetry-sdk/src/logs/log_emitter.rs +++ b/opentelemetry-sdk/src/logs/log_emitter.rs @@ -59,11 +59,19 @@ impl opentelemetry::logs::LoggerProvider for LoggerProvider { fn logger_with_scope(&self, scope: InstrumentationScope) -> Self::Logger { // If the provider is shutdown, new logger will refer a no-op logger provider. if self.inner.is_shutdown.load(Ordering::Relaxed) { + otel_debug!( + name: "LoggerProvider.NoOpLoggerReturned", + logger_name = scope.name(), + ); return Logger::new(scope, noop_logger_provider().clone()); } if scope.name().is_empty() { otel_info!(name: "LoggerNameEmpty", message = "Logger name is empty; consider providing a meaningful name. Logger will function normally and the provided name will be used as-is."); }; + otel_debug!( + name: "LoggerProvider.NewLoggerReturned", + logger_name = scope.name(), + ); Logger::new(scope, self.clone()) } } @@ -92,6 +100,9 @@ impl LoggerProvider { /// Shuts down this `LoggerProvider` pub fn shutdown(&self) -> LogResult<()> { + otel_debug!( + name: "LoggerProvider.ShutdownInvokedByUser", + ); if self .inner .is_shutdown @@ -224,6 +235,10 @@ impl Builder { for processor in logger_provider.log_processors() { processor.set_resource(logger_provider.resource()); } + + otel_debug!( + name: "LoggerProvider.Built", + ); logger_provider } }