Skip to content

Commit 90c1940

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
feat: disable prompt/response content in ADK spans if telemetry env is set
PiperOrigin-RevId: 822709528
1 parent d4e211d commit 90c1940

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

tests/unit/vertex_adk/test_agent_engine_templates_adk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,10 +608,10 @@ def test_span_content_capture_disabled_by_default(self):
608608
@mock.patch.dict(
609609
os.environ, {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true"}
610610
)
611-
def test_span_content_capture_enabled_with_env_var(self):
611+
def test_span_content_capture_disabled_with_env_var(self):
612612
app = agent_engines.AdkApp(agent=_TEST_AGENT)
613613
app.set_up()
614-
assert os.environ["ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS"] == "true"
614+
assert os.environ["ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS"] == "false"
615615

616616
@mock.patch.dict(os.environ)
617617
def test_span_content_capture_enabled_with_tracing(self):

vertexai/agent_engines/templates/adk.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -641,14 +641,10 @@ def set_up(self):
641641
location = self._tmpl_attrs.get("location")
642642
os.environ["GOOGLE_CLOUD_LOCATION"] = location
643643

644-
content_enabled = os.getenv(
645-
"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT", "false"
646-
).lower() in ("true", "1")
647-
# Disable content capture in custom ADK spans unless:
648-
# 1. User opted-in for content capture.
649-
# 2. Or user enabled tracing explicitly with the old flag (this is to
650-
# preserve compatibility with old behavior).
651-
if self._tmpl_attrs.get("enable_tracing") or content_enabled:
644+
# Disable content capture in custom ADK spans unless user enabled
645+
# tracing explicitly with the old flag
646+
# (this is to preserve compatibility with old behavior).
647+
if self._tmpl_attrs.get("enable_tracing"):
652648
os.environ["ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS"] = "true"
653649
else:
654650
os.environ["ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS"] = "false"

0 commit comments

Comments
 (0)