Skip to content

Commit c25bf3a

Browse files
committed
Set CAPTURE_MESSAGE_CONTENT_IN_SPANS default to false
1 parent 509c4aa commit c25bf3a

3 files changed

Lines changed: 10 additions & 14 deletions

File tree

‎core/src/main/java/com/google/adk/telemetry/README.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ The following classes are the primary places where spans are created:
151151

152152
**ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS**: This environment variable controls
153153
whether LLM request/response content and tool arguments/responses are captured
154-
in span attributes. It defaults to `true`. Set to `false` to exclude potentially
155-
large or sensitive data from traces, in which case a `{}` JSON object will be
156-
recorded instead.
154+
in span attributes. It defaults to `false` per OpenTelemetry GenAI semantic
155+
conventions, which classify content attributes as opt-in due to privacy and data
156+
volume concerns. Set to `true` to include content in traces (e.g., for local
157+
development or debugging). When disabled, a `{}` JSON object is recorded instead.

‎core/src/main/java/com/google/adk/telemetry/Tracing.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public class Tracing {
137137

138138
private static final boolean CAPTURE_MESSAGE_CONTENT_IN_SPANS =
139139
Boolean.parseBoolean(
140-
System.getenv().getOrDefault("ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS", "true"));
140+
System.getenv().getOrDefault("ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS", "false"));
141141

142142
private Tracing() {}
143143

‎core/src/test/java/com/google/adk/telemetry/ContextPropagationTest.java‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,7 @@ public void testTraceToolCall() {
257257
assertEquals("tool-name", attrs.get(AttributeKey.stringKey("gen_ai.tool.name")));
258258
assertEquals("tool-description", attrs.get(AttributeKey.stringKey("gen_ai.tool.description")));
259259
assertEquals("tool-type", attrs.get(AttributeKey.stringKey("gen_ai.tool.type")));
260-
assertEquals(
261-
"{\"arg1\":\"value1\"}",
262-
attrs.get(AttributeKey.stringKey("gcp.vertex.agent.tool_call_args")));
260+
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.tool_call_args")));
263261
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.llm_request")));
264262
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.llm_response")));
265263
}
@@ -304,9 +302,7 @@ public void testTraceToolResponse() {
304302
assertEquals("tool-description", attrs.get(AttributeKey.stringKey("gen_ai.tool.description")));
305303
assertEquals("tool-type", attrs.get(AttributeKey.stringKey("gen_ai.tool.type")));
306304
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.tool_call_args")));
307-
assertEquals(
308-
"{\"result\":\"tool-result\"}",
309-
attrs.get(AttributeKey.stringKey("gcp.vertex.agent.tool_response")));
305+
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.tool_response")));
310306
}
311307

312308
@Test
@@ -353,9 +349,8 @@ public void testTraceCallLlm() {
353349
assertEquals(
354350
ImmutableList.of("stop"),
355351
attrs.get(AttributeKey.stringArrayKey("gen_ai.response.finish_reasons")));
356-
assertTrue(
357-
attrs.get(AttributeKey.stringKey("gcp.vertex.agent.llm_request")).contains("gemini-pro"));
358-
assertTrue(attrs.get(AttributeKey.stringKey("gcp.vertex.agent.llm_response")).contains("STOP"));
352+
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.llm_request")));
353+
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.llm_response")));
359354
}
360355

361356
@Test
@@ -379,7 +374,7 @@ public void testTraceSendData() {
379374
"test-invocation-id", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.invocation_id")));
380375
assertEquals("event-1", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.event_id")));
381376
assertEquals("test-session", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.session_id")));
382-
assertTrue(attrs.get(AttributeKey.stringKey("gcp.vertex.agent.data")).contains("hello"));
377+
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.data")));
383378
}
384379

385380
// Agent that emits one event on a computation thread.

0 commit comments

Comments
 (0)