Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions core/src/main/java/com/google/adk/telemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ The following classes are the primary places where spans are created:

**ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS**: This environment variable controls
whether LLM request/response content and tool arguments/responses are captured
in span attributes. It defaults to `true`. Set to `false` to exclude potentially
large or sensitive data from traces, in which case a `{}` JSON object will be
recorded instead.
in span attributes. It defaults to `false` per OpenTelemetry GenAI semantic
conventions, which classify content attributes as opt-in due to privacy and data
volume concerns. Set to `true` to include content in traces (e.g., for local
development or debugging). When disabled, a `{}` JSON object is recorded instead.
2 changes: 1 addition & 1 deletion core/src/main/java/com/google/adk/telemetry/Tracing.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public class Tracing {

private static final boolean CAPTURE_MESSAGE_CONTENT_IN_SPANS =
Boolean.parseBoolean(
System.getenv().getOrDefault("ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS", "true"));
System.getenv().getOrDefault("ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS", "false"));

private Tracing() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,7 @@ public void testTraceToolCall() {
assertEquals("tool-name", attrs.get(AttributeKey.stringKey("gen_ai.tool.name")));
assertEquals("tool-description", attrs.get(AttributeKey.stringKey("gen_ai.tool.description")));
assertEquals("tool-type", attrs.get(AttributeKey.stringKey("gen_ai.tool.type")));
assertEquals(
"{\"arg1\":\"value1\"}",
attrs.get(AttributeKey.stringKey("gcp.vertex.agent.tool_call_args")));
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.tool_call_args")));
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.llm_request")));
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.llm_response")));
}
Expand Down Expand Up @@ -304,9 +302,7 @@ public void testTraceToolResponse() {
assertEquals("tool-description", attrs.get(AttributeKey.stringKey("gen_ai.tool.description")));
assertEquals("tool-type", attrs.get(AttributeKey.stringKey("gen_ai.tool.type")));
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.tool_call_args")));
assertEquals(
"{\"result\":\"tool-result\"}",
attrs.get(AttributeKey.stringKey("gcp.vertex.agent.tool_response")));
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.tool_response")));
}

@Test
Expand Down Expand Up @@ -353,9 +349,8 @@ public void testTraceCallLlm() {
assertEquals(
ImmutableList.of("stop"),
attrs.get(AttributeKey.stringArrayKey("gen_ai.response.finish_reasons")));
assertTrue(
attrs.get(AttributeKey.stringKey("gcp.vertex.agent.llm_request")).contains("gemini-pro"));
assertTrue(attrs.get(AttributeKey.stringKey("gcp.vertex.agent.llm_response")).contains("STOP"));
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.llm_request")));
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.llm_response")));
}

@Test
Expand All @@ -379,7 +374,7 @@ public void testTraceSendData() {
"test-invocation-id", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.invocation_id")));
assertEquals("event-1", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.event_id")));
assertEquals("test-session", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.session_id")));
assertTrue(attrs.get(AttributeKey.stringKey("gcp.vertex.agent.data")).contains("hello"));
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.data")));
}

// Agent that emits one event on a computation thread.
Expand Down