Class Telemetry
java.lang.Object
com.google.adk.Telemetry
Utility class for capturing and reporting telemetry data within the ADK. This class provides
methods to trace various aspects of the agent's execution, including tool calls, tool responses,
LLM interactions, and data handling. It leverages OpenTelemetry for tracing and logging for
detailed information. These traces can then be exported through the ADK Dev Server UI.
-
Method Summary
Modifier and TypeMethodDescriptionstatic io.opentelemetry.api.trace.Tracer
Gets the tracer.static void
traceCallLlm
(InvocationContext invocationContext, String eventId, LlmRequest llmRequest, LlmResponse llmResponse) Traces a call to the LLM.static void
traceSendData
(InvocationContext invocationContext, String eventId, List<com.google.genai.types.Content> data) Traces the sending of data (history or new content) to the agent/model.static void
traceToolCall
(Map<String, Object> args) Traces tool call arguments.static void
traceToolResponse
(InvocationContext invocationContext, String eventId, Event functionResponseEvent) Traces tool response event.
-
Method Details
-
traceToolCall
-
traceToolResponse
public static void traceToolResponse(InvocationContext invocationContext, String eventId, Event functionResponseEvent) Traces tool response event.- Parameters:
invocationContext
- The invocation context for the current agent run.eventId
- The ID of the event.functionResponseEvent
- The function response event.
-
traceCallLlm
public static void traceCallLlm(InvocationContext invocationContext, String eventId, LlmRequest llmRequest, LlmResponse llmResponse) Traces a call to the LLM.- Parameters:
invocationContext
- The invocation context.eventId
- The ID of the event associated with this LLM call/response.llmRequest
- The LLM request object.llmResponse
- The LLM response object.
-
traceSendData
public static void traceSendData(InvocationContext invocationContext, String eventId, List<com.google.genai.types.Content> data) Traces the sending of data (history or new content) to the agent/model.- Parameters:
invocationContext
- The invocation context.eventId
- The ID of the event, if applicable.data
- A list of content objects being sent.
-
getTracer
public static io.opentelemetry.api.trace.Tracer getTracer()Gets the tracer.- Returns:
- The tracer.
-