fix(trace): resolve parent from active context in Tracer.startSpan #164
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 293 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.340
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #164"
general
weight: 0.35
agagniere
Description
Per the OpenTelemetry Trace API Specification: Span Creation:
Previously,
Tracer.startSpaninopentelemetry-sdk/src/sdk/trace/provider.zigonly inspectedoptions.parent_context. Whenoptions.parent_contextwasnull(the default inStartOptions), it completely bypassedcontext.getCurrentContext(), generating a newtrace_idand settingparent_span_id = null. This caused child spans created within an active context (e.g. attached viacontext.attachContextortrace.setCurrentSpan) to become disconnected root spans rather than children of the active span.Additionally,
SpanProcessor.onStartwas always receiving an emptyContext.init()whenoptions.parent_contextwasnull, rather than the resolved parent context as mandated by the SpanProcessor specification.Changes
1. Active Context Fallback:
In
Tracer.startSpan, resolve parent context as:2. Root Span Option:
Added
root: bool = falsetoTracerImpl.StartOptionsallowing callers to explicitly start a root span even when an active context is present on the thread-local context stack.3. SpanProcessor Propagation:
Pass the resolved
parent_contexttoself.provider.onSpanStart(&span, parent_context).4. Unit Tests:
-
Tracer inherits parent from current Context when parent_context is null: verifies child inheritstrace_id,trace_flags, and setsparent_span_idto active parent'sspan_id.-
Tracer.startSpan honors root: true even when a parent Context is active: verifiesroot: truebreaks away from active context to create an independent root trace.-
Tracer passes resolved current Context to SpanProcessor.onStart: verifies thatSpanProcessor.onStartreceives the active parent context.All 480 SDK tests pass cleanly with 0 memory leaks.
Close #163