diff --git a/tracing-opentelemetry/src/subscriber.rs b/tracing-opentelemetry/src/subscriber.rs index 9a781aa9bf..f0936271e8 100644 --- a/tracing-opentelemetry/src/subscriber.rs +++ b/tracing-opentelemetry/src/subscriber.rs @@ -620,8 +620,8 @@ where /// [`ERROR`]: tracing::Level::ERROR /// [`Error`]: opentelemetry::trace::StatusCode::Error fn on_event(&self, event: &Event<'_>, ctx: Context<'_, C>) { - // Ignore events that are not in the context of a span - if let Some(span) = ctx.lookup_current() { + // Ignore events that have no explicit parent set *and* are not in the context of a span + if let Some(span) = ctx.event_span(event) { // Performing read operations before getting a write lock to avoid a deadlock // See https://github.com/tokio-rs/tracing/issues/763 #[cfg(feature = "tracing-log")]