{{ message }}
feat(tracing): record provider response id as gen_ai.response.id#577
Merged
Conversation
ADK drops the litellm response's id when building LlmResponse, so the tracer never sees it. For Volcengine Ark that id == the x-request-id response header, the most useful id for correlating with the provider's logs. A pure litellm callback can read it but runs detached from the OTel context, so it can't attach to the LLM span. Instead, a self-contained tracing module wraps LiteLLMClient.acompletion in-context (where the raw response is available, inside ADK's generate_content span) and sets the standard OTel GenAI attribute gen_ai.response.id on the current span. The wrap is applied lazily only when a VeADK OpenTelemetry tracer is created (same pattern as patch_google_adk_telemetry); no agent.py change, no model subclass, and a no-op when tracing is off. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
zakahan
approved these changes
Jun 2, 2026
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.

What
Records the model provider's response id on the LLM trace span as the standard OpenTelemetry GenAI attribute
gen_ai.response.id.For Volcengine Ark this id equals the
x-request-idresponse header — the most useful identifier when correlating with the provider's logs / filing tickets.Why it's done this way
LlmResponsefrom the litellm response's message/model/usage but dropsresponse.id, so the tracer never sees it.get_current_span()is non-recording there), so it can't attach the id to the LLM span.LiteLLMClient.acompletionin-context (where the raw response is available, inside ADK'sgenerate_contentspan) and setsgen_ai.response.idon the current span.Scope / safety
veadk/tracing/telemetry/litellm_response_id.py+ one lazy registration line inOpentelemetryTracer(same pattern as the existingpatch_google_adk_telemetry).agent.pychange, no model subclass. The wrap is applied only when a VeADK OpenTelemetry tracer is created; with no tracer nothing is patched, and when patched-but-not-recording it's a no-op.Verified locally (real Ark call)
With a tracer enabled, the
generate_contentspan'sgen_ai.response.idexactly equals the live Arkresponse.id:🤖 Generated with Claude Code