Skip to content

Commit 6f92934

Browse files
Merge pull request #1144 from r4inee:feature/default-message-content-in-tracing-to-false
PiperOrigin-RevId: 1004753853
2 parents 4d05a08 + 81a6a04 commit 6f92934

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
@@ -152,6 +152,7 @@ The following classes are the primary places where spans are created:
152152

153153
**ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS**: This environment variable controls
154154
whether LLM request/response content and tool arguments/responses are captured
155-
in span attributes. It defaults to `true`. Set to `false` to exclude potentially
156-
large or sensitive data from traces, in which case a `{}` JSON object will be
157-
recorded instead.
155+
in span attributes. It defaults to `false` per OpenTelemetry GenAI semantic
156+
conventions, which classify content attributes as opt-in due to privacy and data
157+
volume concerns. Set to `true` to include content in traces (e.g., for local
158+
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
@@ -146,7 +146,7 @@ public class Tracing {
146146

147147
private static final boolean CAPTURE_MESSAGE_CONTENT_IN_SPANS =
148148
Boolean.parseBoolean(
149-
System.getenv().getOrDefault("ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS", "true"));
149+
System.getenv().getOrDefault("ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS", "false"));
150150

151151
private Tracing() {}
152152

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

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,7 @@ public void testTraceToolCall() {
324324
assertEquals("tool-name", attrs.get(AttributeKey.stringKey("gen_ai.tool.name")));
325325
assertEquals("tool-description", attrs.get(AttributeKey.stringKey("gen_ai.tool.description")));
326326
assertEquals("tool-type", attrs.get(AttributeKey.stringKey("gen_ai.tool.type")));
327-
assertEquals(
328-
"{\"arg1\":\"value1\"}",
329-
attrs.get(AttributeKey.stringKey("gcp.vertex.agent.tool_call_args")));
327+
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.tool_call_args")));
330328
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.llm_request")));
331329
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.llm_response")));
332330
}
@@ -371,9 +369,7 @@ public void testTraceToolResponse() {
371369
assertEquals("tool-description", attrs.get(AttributeKey.stringKey("gen_ai.tool.description")));
372370
assertEquals("tool-type", attrs.get(AttributeKey.stringKey("gen_ai.tool.type")));
373371
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.tool_call_args")));
374-
assertEquals(
375-
"{\"result\":\"tool-result\"}",
376-
attrs.get(AttributeKey.stringKey("gcp.vertex.agent.tool_response")));
372+
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.tool_response")));
377373
}
378374

379375
@Test
@@ -420,9 +416,8 @@ public void testTraceCallLlm() {
420416
assertEquals(
421417
ImmutableList.of("stop"),
422418
attrs.get(AttributeKey.stringArrayKey("gen_ai.response.finish_reasons")));
423-
assertTrue(
424-
attrs.get(AttributeKey.stringKey("gcp.vertex.agent.llm_request")).contains("gemini-pro"));
425-
assertTrue(attrs.get(AttributeKey.stringKey("gcp.vertex.agent.llm_response")).contains("STOP"));
419+
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.llm_request")));
420+
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.llm_response")));
426421
}
427422

428423
@Test
@@ -618,7 +613,7 @@ public void testTraceSendData() {
618613
"test-invocation-id", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.invocation_id")));
619614
assertEquals("event-1", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.event_id")));
620615
assertEquals("test-session", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.session_id")));
621-
assertTrue(attrs.get(AttributeKey.stringKey("gcp.vertex.agent.data")).contains("hello"));
616+
assertEquals("{}", attrs.get(AttributeKey.stringKey("gcp.vertex.agent.data")));
622617
}
623618

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

0 commit comments

Comments
 (0)