fix(sdk): Get trace context from provider#211
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| """ | ||
| provider_context = get_trace_context_from_provider() | ||
| if provider_context is not None: | ||
| return provider_context["trace_id"], provider_context["span_id"] |
There was a problem hiding this comment.
With a provider registered, this returns the provider's span_id verbatim, so every @control() call inside one provider-owned span now reports under the same (trace_id, span_id) pair — both the pre and post _evaluate POSTs, and any stacked decorators in the same trace. The docstring above frames this as intentional. Flagging as FYI: this is a semantic change from the old path, where get_current_trace_id() already returned the provider's trace_id and _generate_span_id() was minted fresh per decorated call (see tracing.py:147-150). Consumers that group control events by (trace_id, span_id) will now see them collapse onto one span; if the bridge keys events by control_execution_id this is fine. Worth a brief inline code comment so future readers don't expect a fresh span per decorator like the fallback branches still produce.
Summary
Scope
Get provider specific trace context if available else get current trace_id and span_id.
Risk and Rollout
Testing
make check(or explained why not)