Skip to content

Commit

Permalink
Minor Internal logs (#2361)
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas authored Nov 27, 2024
1 parent cbe9ebe commit b7276d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/self-diagnostics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}
15 changes: 15 additions & 0 deletions opentelemetry-sdk/src/logs/log_emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit b7276d8

Please sign in to comment.