feat(tracing): adopt ambient W3C/OTel trace id for agent spans#470
Closed
mohammadatallah-scale wants to merge 2 commits into
Closed
feat(tracing): adopt ambient W3C/OTel trace id for agent spans#470mohammadatallah-scale wants to merge 2 commits into
mohammadatallah-scale wants to merge 2 commits into
Conversation
Agentex hard-passed its own task/thread id as the SGP trace_id, which overrode the SDK's W3C adoption and kept agent traces on a separate id namespace from the observability trace. _build_sgp_span now prefers the active OTel/W3C trace id (falling back to agentex's id when no OTel context is present) and preserves the original id in span metadata. This is a no-op until the agent runtime carries an OTel context; the entrypoint instrumentation that establishes it is the remaining follow-up. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
span.data is Optional; assert it is a dict before indexing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author
|
Closing as superseded by #465. That PR solves the same agentex business-span ↔ observability-trace correlation with the correct non-destructive design: it keeps the run-level business |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Agentex hard-passes its own task/thread id as the SGP
trace_id(_build_sgp_span), which overrides the SDK's W3C adoption. So even with the SDK change (scaleapi/sgp-python-beta#178), agent-originated business traces stay on a separate id namespace from the observability trace. This closes that gap.What changed
_build_sgp_spannow setstrace_id=_resolve_trace_id(span.trace_id): prefer the active OTel/W3C trace id (32-hex), fall back to agentex's own id when no OTel context is present._add_source_to_spanstamps the original agentex id into span metadata (__agentex_trace_id__) so the task linkage survives once the SGP trace_id adopts the W3C id.Behavior
No-op today: agentex has no OTel context at its entrypoint, so
_active_otel_trace_id()returns None and the agentex id is kept (unchanged behavior). It activates automatically once the agent runtime carries a W3C context.Test plan
SpanContext→ 32-hex; metadata preserves the agentex id (test_sgp_tracing_processor.py)Remaining follow-up (separate)
Instrument the agentex request entrypoint (ACP server) to establish an OTel context from the inbound W3C
traceparent. Until then this seam is inert. Likely belongs to the OTel Integration effort.Part of the trace-id unification epic (OVE-350). Pairs with sgp-python-beta#178, scaleapi#153175, scaleapi/sgp#4271.