🔴 Required Information
Please ensure all items in this section are completed to allow for efficient
triaging. Requests without complete information may be rejected / deprioritized.
If an item is not applicable to you - please mark it as N/A
Describe the Bug:
When the ADK API server (get_fast_api_app) receives inbound HTTP requests containing W3C traceparent headers, the headers are ignored. The server starts new trace roots instead of joining the caller's trace. This breaks distributed trace correlation for any service calling the ADK agent over HTTP.
The root cause is that AdkWebServer.get_fast_api_app() creates a TracerProvider and configures W3C TraceContextTextMapPropagator, but never applies FastAPIInstrumentor to the FastAPI app. Without the ASGI instrumentation middleware, the traceparent header on inbound requests is never extracted, so each request starts a new trace.
Steps to Reproduce:
- Deploy an ADK agent with get_fast_api_app(agents_dir=..., web=False)
- Set OTEL_EXPORTER_OTLP_ENDPOINT to a Jaeger/collector endpoint and OTEL_SERVICE_NAME to identify the agent
- From a calling service (e.g. Next.js with @opentelemetry/sdk-node), send a request to the agent's /run_sse endpoint — the caller's OTel SDK will automatically attach a traceparent header
- Observe in Jaeger that the caller and agent traces are separate trace roots with different trace IDs, rather than a single correlated trace
Expected Behavior:
The ADK server should extract the traceparent header from inbound HTTP requests and create child spans under the caller's trace, producing a single end-to-end distributed trace (e.g. caller → agent → LLM).
Observed Behavior:
The agent creates a new trace root for every request. The caller's trace ends at the outbound fetch span, and the agent's spans appear as a disconnected trace in Jaeger. The traceparent header is present on the wire but never consumed.
Workaround: manually applying FastAPIInstrumentor().instrument_app(app) after get_fast_api_app() returns fixes the issue, since the TracerProvider and TraceContextTextMapPropagator are already correctly configured by the ADK.
Environment Details:
- ADK Library Version: google-adk 1.25.0
- Desktop OS: Linux 6.10.14-linuxkit (Docker)
- Python Version: 3.14.3
Model Information:
- Are you using LiteLLM: No
- Which model is being used: gemini-2.5-flash
🟡 Optional Information
Providing this information greatly speeds up the resolution process.
Regression:
N/A — the ADK has never applied FastAPIInstrumentor to the app returned by get_fast_api_app(). The _setup_instrumentation_lib_if_installed() function only instruments GoogleGenAiSdkInstrumentor, not FastAPI.
Logs:
Verified by inspecting the ADK source:
# In AdkWebServer.get_fast_api_app():
# _setup_telemetry() → configures TracerProvider + W3C propagator ✓
# _setup_instrumentation_lib_if_installed() → only instruments GoogleGenAiSdkInstrumentor ✗
# FastAPIInstrumentor is never called on the app ✗
# Propagator IS correctly configured:
>>> from opentelemetry import propagate
>>> p = propagate.get_global_textmap()
>>> [type(x).__name__ for x in p._propagators]
['TraceContextTextMapPropagator', 'W3CBaggagePropagator']
# But without FastAPI middleware, the propagator is never invoked on inbound requests.
Minimal Reproduction Code:
Please provide a code snippet or a link to a Gist/repo that isolates the issue.
# server.py — ADK agent server
from google.adk.cli.fast_api import get_fast_api_app
app = get_fast_api_app(agents_dir="./agents", web=False)
# No FastAPIInstrumentor applied → traceparent ignored
# caller.py — service calling the agent
import httpx
from opentelemetry import trace
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span("call-agent"):
# OTel httpx instrumentation injects traceparent header automatically
resp = httpx.post("http://agent:8000/run_sse", json={...})
# Agent receives traceparent but creates a new trace root
How often has this issue occurred?:
Suggested Fix
In AdkWebServer.get_fast_api_app(), after the app is created, add:
try:
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
FastAPIInstrumentor().instrument_app(app)
except ImportError:
pass
This is consistent with how _setup_instrumentation_lib_if_installed() already handles GoogleGenAiSdkInstrumentor with a try/except ImportError pattern.
🔴 Required Information
Please ensure all items in this section are completed to allow for efficient
triaging. Requests without complete information may be rejected / deprioritized.
If an item is not applicable to you - please mark it as N/A
Describe the Bug:
When the ADK API server (get_fast_api_app) receives inbound HTTP requests containing W3C traceparent headers, the headers are ignored. The server starts new trace roots instead of joining the caller's trace. This breaks distributed trace correlation for any service calling the ADK agent over HTTP.
The root cause is that AdkWebServer.get_fast_api_app() creates a TracerProvider and configures W3C TraceContextTextMapPropagator, but never applies FastAPIInstrumentor to the FastAPI app. Without the ASGI instrumentation middleware, the traceparent header on inbound requests is never extracted, so each request starts a new trace.
Steps to Reproduce:
Expected Behavior:
The ADK server should extract the traceparent header from inbound HTTP requests and create child spans under the caller's trace, producing a single end-to-end distributed trace (e.g. caller → agent → LLM).
Observed Behavior:
The agent creates a new trace root for every request. The caller's trace ends at the outbound fetch span, and the agent's spans appear as a disconnected trace in Jaeger. The traceparent header is present on the wire but never consumed.
Workaround: manually applying FastAPIInstrumentor().instrument_app(app) after get_fast_api_app() returns fixes the issue, since the TracerProvider and TraceContextTextMapPropagator are already correctly configured by the ADK.
Environment Details:
Model Information:
🟡 Optional Information
Providing this information greatly speeds up the resolution process.
Regression:
N/A — the ADK has never applied FastAPIInstrumentor to the app returned by get_fast_api_app(). The _setup_instrumentation_lib_if_installed() function only instruments GoogleGenAiSdkInstrumentor, not FastAPI.
Logs:
Verified by inspecting the ADK source:
Minimal Reproduction Code:
Please provide a code snippet or a link to a Gist/repo that isolates the issue.
How often has this issue occurred?:
Suggested Fix
In AdkWebServer.get_fast_api_app(), after the app is created, add:
This is consistent with how _setup_instrumentation_lib_if_installed() already handles GoogleGenAiSdkInstrumentor with a try/except ImportError pattern.