Skip to content

[#16670] dist-trace: async scope-carry across thread hops - #14

Open
ellabaron-code wants to merge 1 commit into
dist-trace-02-distlibfrom
dist-trace-03-scopecarry
Open

[#16670] dist-trace: async scope-carry across thread hops#14
ellabaron-code wants to merge 1 commit into
dist-trace-02-distlibfrom
dist-trace-03-scopecarry

Conversation

@ellabaron-code

Copy link
Copy Markdown

Carry the active OTel trace context across thread boundaries so work
resumed on a worker/reactor thread nests under the trace that submitted
it. Each carrier captures dist_trace::GetActiveSpanContext() where the
scope is still live (Enqueue / construction) and re-establishes it with
dist_trace::ActivateParentScope() around the deferred callback.

  • util/thread_pool: ThreadPoolTask carries trace_parent_; captured in
    YBThreadPool::Enqueue and TaskRecipient::StampTraceContext, re-activated
    in the worker loop and FunctorThreadPoolTask::Run.
  • util/strand: StrandTask carries trace_parent_; captured in
    Strand::Enqueue, re-activated in Strand::Task::Done.
  • rpc/scheduler: ScheduledTaskBase captures at construction, re-activates
    in ScheduledTask{,WithId}::Run.
  • rpc/periodic: PeriodicTimer captures at construction, re-activates in
    Callback before running the task.
  • rpc/rpc: RpcRetrier captures at construction, re-activates in DoRetry
    before rebuilding the OutboundCall (carries the parent across retries).

Purely additive; all no-ops when the captured context is invalid.

@ellabaron-code

Copy link
Copy Markdown
Author

Misfiled: reopening against yugabyte/yugabyte-db.

@ellabaron-code
ellabaron-code force-pushed the dist-trace-03-scopecarry branch from 9c05fe5 to 9ce570b Compare July 11, 2026 02:15
@ellabaron-code
ellabaron-code force-pushed the dist-trace-02-distlib branch from bd290ce to 28f5f4f Compare July 11, 2026 02:15
@ellabaron-code ellabaron-code changed the title dist-trace: async scope-carry across thread hops [#16670] dist-trace: async scope-carry across thread hops Jul 11, 2026
@ellabaron-code
ellabaron-code force-pushed the dist-trace-02-distlib branch from 28f5f4f to 24f800a Compare July 13, 2026 15:13
@ellabaron-code
ellabaron-code force-pushed the dist-trace-03-scopecarry branch from 9ce570b to e20a47f Compare July 13, 2026 15:13
Carry the active OTel trace context across thread boundaries so work
resumed on a worker/reactor thread nests under the trace that submitted
it. Each carrier captures dist_trace::GetActiveSpanContext() where the
scope is still live (Enqueue / construction) and re-establishes it with
dist_trace::ActivateParentScope() around the deferred callback.

- util/thread_pool: ThreadPoolTask carries trace_parent_; captured in
  YBThreadPool::Enqueue and TaskRecipient::StampTraceContext, re-activated
  in the worker loop and FunctorThreadPoolTask::Run.
- util/strand: StrandTask carries trace_parent_; captured in
  Strand::Enqueue, re-activated in Strand::Task::Done.
- rpc/scheduler: ScheduledTaskBase captures at construction, re-activates
  in ScheduledTask{,WithId}::Run.
- rpc/periodic: PeriodicTimer captures at construction, re-activates in
  Callback before running the task.
- rpc/rpc: RpcRetrier captures at construction, re-activates in DoRetry
  before rebuilding the OutboundCall (carries the parent across retries).

Purely additive; all no-ops when the captured context is invalid.
@ellabaron-code
ellabaron-code force-pushed the dist-trace-02-distlib branch from 24f800a to 77539c4 Compare July 13, 2026 16:12
@ellabaron-code
ellabaron-code force-pushed the dist-trace-03-scopecarry branch from e20a47f to 61c5f9e Compare July 13, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant