diff --git a/core/src/main/java/com/google/adk/telemetry/README.md b/core/src/main/java/com/google/adk/telemetry/README.md index 8665b3352..a07e75bac 100644 --- a/core/src/main/java/com/google/adk/telemetry/README.md +++ b/core/src/main/java/com/google/adk/telemetry/README.md @@ -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. diff --git a/core/src/main/java/com/google/adk/telemetry/Tracing.java b/core/src/main/java/com/google/adk/telemetry/Tracing.java index 589215073..bf0902ae5 100644 --- a/core/src/main/java/com/google/adk/telemetry/Tracing.java +++ b/core/src/main/java/com/google/adk/telemetry/Tracing.java @@ -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() {} diff --git a/core/src/test/java/com/google/adk/telemetry/ContextPropagationTest.java b/core/src/test/java/com/google/adk/telemetry/ContextPropagationTest.java index 44877e972..6799ebf72 100644 --- a/core/src/test/java/com/google/adk/telemetry/ContextPropagationTest.java +++ b/core/src/test/java/com/google/adk/telemetry/ContextPropagationTest.java @@ -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"))); } @@ -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 @@ -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 @@ -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.