Skip to content

Commit 052558c

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 f84739c commit 052558c

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

tests/unit/vertex_adk/test_agent_engine_templates_adk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,10 @@ def test_span_content_capture_disabled_by_default(self):
590590
@mock.patch.dict(
591591
os.environ, {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true"}
592592
)
593-
def test_span_content_capture_enabled_with_env_var(self):
593+
def test_span_content_capture_disabled_with_env_var(self):
594594
app = agent_engines.AdkApp(agent=_TEST_AGENT)
595595
app.set_up()
596-
assert os.environ["ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS"] == "true"
596+
assert os.environ["ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS"] == "false"
597597

598598
@mock.patch.dict(os.environ)
599599
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
@@ -634,14 +634,10 @@ def set_up(self):
634634
location = self._tmpl_attrs.get("location")
635635
os.environ["GOOGLE_CLOUD_LOCATION"] = location
636636

637-
content_enabled = os.getenv(
638-
"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT", "false"
639-
).lower() in ("true", "1")
640-
# Disable content capture in custom ADK spans unless:
641-
# 1. User opted-in for content capture.
642-
# 2. Or user enabled tracing explicitly with the old flag (this is to
643-
# preserve compatibility with old behavior).
644-
if self._tmpl_attrs.get("enable_tracing") or content_enabled:
637+
# Disable content capture in custom ADK spans unless user enabled
638+
# tracing explicitly with the old flag
639+
# (this is to preserve compatibility with old behavior).
640+
if self._tmpl_attrs.get("enable_tracing"):
645641
os.environ["ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS"] = "true"
646642
else:
647643
os.environ["ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS"] = "false"

0 commit comments

Comments
 (0)