feat: Updating the Tracing implementation and updating BaseAgent.runLive - #837
Merged
Conversation
copybara-service
Bot
force-pushed
the
test_867888690
branch
4 times, most recently
from
February 10, 2026 12:39
b2d683b to
974b510
Compare
copybara-service
Bot
force-pushed
the
test_867888690
branch
5 times, most recently
from
February 10, 2026 21:33
1ecab47 to
2f01d05
Compare
This update should make the java tracing consistent with Python ADK:
1. **`BaseAgent.java`**:
* The `runAsync` and `runLive` methods have been modified to create the `InvocationContext` before starting the tracing span.
* The span name for agent invocations has been changed from `"agent_run [<agent name>]"` to `"invoke_agent <agent name>"`.
* A new `Tracing.traceAgentInvocation` method is now called to add initial tracing attributes for the agent invocation.
* In `runLive`, the `runLiveImpl` execution is now wrapped with calls to `beforeAgentCallback` and `afterAgentCallback` to ensure proper tracing of these lifecycle events.
2. **`Tracing.java`**:
* The OpenTelemetry tracer name has been updated from `"com.google.adk"` to `"gcp.vertex.agent"`.
* A new `traceAgentInvocation` method has been added to set standard attributes for agent invocation spans, including `gen_ai.operation.name`, `gen_ai.agent.description`, `gen_ai.agent.name`, and `gen_ai.conversation.id`.
* Attribute keys used in `traceToolCall`, `traceToolResponse`, `traceCallLlm`, and `traceSendData` have been updated to use the `"gcp.vertex.agent."` prefix instead of `"adk."` or `"com.google.adk"`.
* The serialization of message content (like tool call arguments, tool responses, and data) is now guarded by the `CAPTURE_MESSAGE_CONTENT_IN_SPANS` flag. When disabled, empty JSON objects are recorded instead.
* `traceToolResponse` now includes logic to extract and trace the `tool_call.id` and the tool response content from `FunctionResponse` objects.
* `traceCallLlm` now captures additional LLM request and response details, such as `gen_ai.request.top_p`, `gen_ai.request.max_tokens`, `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, and `gen_ai.response.finish_reasons`.
PiperOrigin-RevId: 868299966
copybara-service
Bot
force-pushed
the
test_867888690
branch
from
February 10, 2026 21:43
2f01d05 to
8acb1ea
Compare
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.
feat: Updating the Tracing implementation and updating BaseAgent.runLive
This update should make the java tracing consistent with Python ADK:
BaseAgent.java:runAsyncandrunLivemethods have been modified to create theInvocationContextbefore starting the tracing span."agent_run [<agent name>]"to"invoke_agent <agent name>".Tracing.traceAgentInvocationmethod is now called to add initial tracing attributes for the agent invocation.runLive, therunLiveImplexecution is now wrapped with calls tobeforeAgentCallbackandafterAgentCallbackto ensure proper tracing of these lifecycle events.Tracing.java:"com.google.adk"to"gcp.vertex.agent".traceAgentInvocationmethod has been added to set standard attributes for agent invocation spans, includinggen_ai.operation.name,gen_ai.agent.description,gen_ai.agent.name, andgen_ai.conversation.id.traceToolCall,traceToolResponse,traceCallLlm, andtraceSendDatahave been updated to use the"gcp.vertex.agent."prefix instead of"adk."or"com.google.adk".CAPTURE_MESSAGE_CONTENT_IN_SPANSflag. When disabled, empty JSON objects are recorded instead.traceToolResponsenow includes logic to extract and trace thetool_call.idand the tool response content fromFunctionResponseobjects.traceCallLlmnow captures additional LLM request and response details, such asgen_ai.request.top_p,gen_ai.request.max_tokens,gen_ai.usage.input_tokens,gen_ai.usage.output_tokens, andgen_ai.response.finish_reasons.