When OpenTelemetry tracing is enabled in the ADK, the span_id no longer matches between LLM_REQUEST and its corresponding LLM_RESPONSE (and LLM_ERROR) events.
This happens because before_model_callback runs before the framework's internal call_llm span begins. As a result, the BigQueryAgentAnalyticsPlugin grabs the parent span ID (e.g. from the execute_tool span) to log the LLM_REQUEST. Then, the model executes inside the child call_llm span. The on_model_error_callback and after_model_callback then execute within that child span.
Because of this, LLM_REQUEST.span_id == LLM_RESPONSE.parent_span_id.
This can break any downstream data warehouses or analysis tools that rightfully expect an atomic request/response LLM pair to share the identical span_id. Notably, without OpenTelemetry, span_id matches perfectly between all three events
When querying raw event tables with OTel enabled:
TOOL_STARTING to TOOL_COMPLETED still match perfectly on span_id.
AGENT_STARTING to AGENT_COMPLETED still match perfectly on span_id.
The issue is completely isolated to the LLM flow callbacks.
When OpenTelemetry tracing is enabled in the ADK, the
span_idno longer matches betweenLLM_REQUESTand its correspondingLLM_RESPONSE(andLLM_ERROR) events.This happens because
before_model_callbackruns before the framework's internalcall_llmspan begins. As a result, theBigQueryAgentAnalyticsPlugingrabs the parent span ID (e.g. from theexecute_toolspan) to log theLLM_REQUEST. Then, the model executes inside the childcall_llmspan. Theon_model_error_callbackandafter_model_callbackthen execute within that child span.Because of this,
LLM_REQUEST.span_id==LLM_RESPONSE.parent_span_id.This can break any downstream data warehouses or analysis tools that rightfully expect an atomic request/response LLM pair to share the identical
span_id. Notably, without OpenTelemetry,span_idmatches perfectly between all three eventsWhen querying raw event tables with OTel enabled:
TOOL_STARTINGtoTOOL_COMPLETEDstill match perfectly onspan_id.AGENT_STARTINGtoAGENT_COMPLETEDstill match perfectly onspan_id.The issue is completely isolated to the LLM flow callbacks.