Skip to content

fix(telemetry): extract W3C traceparent/baggage when AE header is absent - #7846

Closed
ninglinLiu wants to merge 14 commits into
google:mainfrom
ninglinLiu:fix/7844-w3c-traceparent-baggage
Closed

ninglinLiu wants to merge 14 commits into
google:mainfrom
ninglinLiu:fix/7844-w3c-traceparent-baggage

Conversation

@ninglinLiu

Copy link
Copy Markdown
Contributor

Description

Fixes #7844

get_propagated_context() only extracted Google-Agent-Engine-Traceparent for the parent span context. A standard W3C traceparent was stored only as the support-ID baggage value, so adk api_server / adk web started a new trace for ordinary callers. Inbound W3C baggage was ignored.

This change:

  • Extracts W3C traceparent / tracestate when the Agent Engine header is absent, so ADK spans join the caller's trace.
  • Extracts W3C baggage, then re-applies internal google_traceparent / traceparent keys so callers cannot clobber them.
  • Keeps Agent Engine parent precedence when both headers are present (existing support-ID behavior unchanged).

Testing

  • pytest tests/unittests/telemetry/test_agent_engine.py — 43 passed
  • Added coverage for standard W3C parent join, baggage extraction without clobbering, and AE precedence

This PR was prepared with AI assistance and reviewed/tested by the author.

Fixes google#7844.

get_propagated_context only joined traces via Google-Agent-Engine-Traceparent.
Extract standard W3C traceparent/tracestate when that header is missing, and
extract W3C baggage without letting callers clobber internal baggage keys.
Agent Engine parent still wins when both headers are present.

This PR was prepared with AI assistance and reviewed/tested by the author.
@jawoszek jawoszek assigned RKest and unassigned jawoszek Nov 2, 2026
@GWeale
GWeale self-requested a review November 4, 2026 18:40
@GWeale GWeale self-assigned this Nov 4, 2026
@GWeale

GWeale commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

thanks for sending this in first, @ninglinLiu. f27b8f1 fixes the same issue on main: fastapi requests now read standard w3c traceparent, tracestate and baggage headers when the agent engine header is absent, and your three new tests pass against main. it's on main now and not in a release yet. please open a new issue if you still see this happening.

@GWeale GWeale closed this Nov 4, 2026
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.

get_propagated_context() ignores standard W3C traceparent and baggage headers on FastAPI requests unless Google-Agent-Engine-Traceparent is set

4 participants