From 5150159ca2165ce62223066781bb8a1240e84252 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Wed, 22 Jul 2026 13:30:50 +0100 Subject: [PATCH] refactor(telemetry): ledger.acquire uses thread-free SpanGuard (no detach) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit acquireSpan_ is emplaced on the acquiring thread and reset() on a JtLedgerData worker. SpanGuard is now thread-free (owns no thread-local Scope), so it can be created here and destroyed on the worker with no scope to strip — dropping the .detached() call the old scoped SpanGuard required. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/xrpld/app/ledger/detail/InboundLedger.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/xrpld/app/ledger/detail/InboundLedger.cpp b/src/xrpld/app/ledger/detail/InboundLedger.cpp index 84f77e5d95..bb0b2ee8e0 100644 --- a/src/xrpld/app/ledger/detail/InboundLedger.cpp +++ b/src/xrpld/app/ledger/detail/InboundLedger.cpp @@ -103,12 +103,11 @@ InboundLedger::init(ScopedLockType& collectionLock) // observable. Finalized in done() with the outcome and timeout count. { using namespace telemetry; - // Detach the Scope: this guard is emplaced here but reset() on a - // JtLedgerData worker thread. Detaching strips the thread-local Scope - // so its destruction there does not corrupt this thread's context stack. + // acquireSpan_ is emplaced here but reset() on a JtLedgerData worker + // thread. A SpanGuard is thread-free (owns no thread-local Scope), so it + // can be created here and destroyed on the worker with no scope to strip. acquireSpan_.emplace( - SpanGuard::span(TraceCategory::Ledger, seg::ledger, ledger_span::op::acquire) - .detached()); + SpanGuard::span(TraceCategory::Ledger, seg::ledger, ledger_span::op::acquire)); if (*acquireSpan_) { acquireSpan_->setAttribute(ledger_span::attr::ledgerSeq, static_cast(seq_));