From 417f990b23343e9ec2573a9da4c50606af598f7a Mon Sep 17 00:00:00 2001 From: Conrad Ludgate Date: Tue, 27 May 2025 21:09:16 +0100 Subject: [PATCH] remove span clone on enter --- tracing-subscriber/src/registry/sharded.rs | 12 +++--------- tracing-subscriber/src/registry/stack.rs | 3 +-- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/tracing-subscriber/src/registry/sharded.rs b/tracing-subscriber/src/registry/sharded.rs index 2e8e19cc8f..8dc7d1960a 100644 --- a/tracing-subscriber/src/registry/sharded.rs +++ b/tracing-subscriber/src/registry/sharded.rs @@ -287,21 +287,15 @@ impl Collect for Registry { fn event(&self, _: &Event<'_>) {} fn enter(&self, id: &span::Id) { - if self - .current_spans + self.current_spans .get_or_default() .borrow_mut() - .push(id.clone()) - { - self.clone_span(id); - } + .push(id.clone()); } fn exit(&self, id: &span::Id) { if let Some(spans) = self.current_spans.get() { - if spans.borrow_mut().pop(id) { - dispatch::get_default(|dispatch| dispatch.try_close(id.clone())); - } + spans.borrow_mut().pop(id); } } diff --git a/tracing-subscriber/src/registry/stack.rs b/tracing-subscriber/src/registry/stack.rs index 4a3f7e59d8..dd35104b40 100644 --- a/tracing-subscriber/src/registry/stack.rs +++ b/tracing-subscriber/src/registry/stack.rs @@ -17,10 +17,9 @@ pub(crate) struct SpanStack { impl SpanStack { #[inline] - pub(super) fn push(&mut self, id: Id) -> bool { + pub(super) fn push(&mut self, id: Id) { let duplicate = self.stack.iter().any(|i| i.id == id); self.stack.push(ContextId { id, duplicate }); - !duplicate } #[inline]