Skip to content

Commit 5ac0748

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
chore: add warning to ADK deployment if tracing is disabled.
PiperOrigin-RevId: 826025444
1 parent 9a46e67 commit 5ac0748

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed

tests/unit/vertex_adk/test_agent_engine_templates_adk.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,22 @@ def test_enable_tracing_warning(self, caplog):
709709
# app.set_up()
710710
# assert "enable_tracing=True but proceeding with tracing disabled" in caplog.text
711711

712+
# TODO(b/384730642): Re-enable this test once the parent issue is fixed.
713+
# @pytest.mark.parametrize(
714+
# "enable_tracing,want_warning",
715+
# [
716+
# (True, False),
717+
# (False, True),
718+
# (None, False),
719+
# ],
720+
# )
721+
# @pytest.mark.usefixtures("caplog")
722+
# def test_tracing_disabled_warning(self, enable_tracing, want_warning, caplog):
723+
# _ = agent_engines.AdkApp(agent=_TEST_AGENT, enable_tracing=enable_tracing)
724+
# assert (
725+
# "[WARNING] Your 'enable_tracing=False' setting" in caplog.text
726+
# ) == want_warning
727+
712728
@mock.patch.dict(os.environ)
713729
def test_span_content_capture_disabled_by_default(self):
714730
app = agent_engines.AdkApp(agent=_TEST_AGENT)

tests/unit/vertex_adk/test_reasoning_engine_templates_adk.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,25 @@ def test_enable_tracing_warning(self, caplog):
688688
# app.set_up()
689689
# assert "enable_tracing=True but proceeding with tracing disabled" in caplog.text
690690

691+
# TODO(b/384730642): Re-enable this test once the parent issue is fixed.
692+
# @pytest.mark.parametrize(
693+
# "enable_tracing,want_warning",
694+
# [
695+
# (True, False),
696+
# (False, True),
697+
# (None, False),
698+
# ],
699+
# )
700+
# @pytest.mark.usefixtures("caplog")
701+
# def test_tracing_disabled_warning(self, enable_tracing, want_warning, caplog):
702+
# app = reasoning_engines.AdkApp(
703+
# agent=Agent(name=_TEST_AGENT_NAME, model=_TEST_MODEL),
704+
# enable_tracing=enable_tracing
705+
# )
706+
# assert (
707+
# "[WARNING] Your 'enable_tracing=False' setting" in caplog.text
708+
# ) == want_warning
709+
691710

692711
def test_dump_event_for_json():
693712
from google.adk.events import event

vertexai/agent_engines/templates/adk.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,25 @@ def set_up(self):
711711

712712
custom_instrumentor = self._tmpl_attrs.get("instrumentor_builder")
713713

714+
if self._tmpl_attrs.get("enable_tracing") is False:
715+
_warn(
716+
(
717+
"Your 'enable_tracing=False' setting is being deprecated "
718+
"and will be removed in a future release.\n"
719+
"This legacy setting overrides the new Cloud Console toggle "
720+
"and environment variable controls.\n"
721+
"Impact: The Cloud Console may incorrectly show telemetry as "
722+
"'On' when it is actually 'Off', and the UI toggle will not "
723+
"work.\n"
724+
"Action: To fix this and control telemetry, please remove the "
725+
"'enable_tracing' parameter from your deployment code.\n"
726+
"You can then use the "
727+
"'GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY' "
728+
"environment variable or the toggle in the Cloud Console: "
729+
"https://console.cloud.google.com/vertex-ai/agents."
730+
),
731+
)
732+
714733
if custom_instrumentor and self._tracing_enabled():
715734
self._tmpl_attrs["instrumentor"] = custom_instrumentor(project)
716735

vertexai/preview/reasoning_engines/templates/adk.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,25 @@ def set_up(self):
644644
else:
645645
os.environ["ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS"] = "false"
646646

647+
if self._tmpl_attrs.get("enable_tracing") is False:
648+
_warn(
649+
(
650+
"Your 'enable_tracing=False' setting is being deprecated "
651+
"and will be removed in a future release.\n"
652+
"This legacy setting overrides the new Cloud Console toggle "
653+
"and environment variable controls.\n"
654+
"Impact: The Cloud Console may incorrectly show telemetry as "
655+
"'On' when it is actually 'Off', and the UI toggle will not "
656+
"work.\n"
657+
"Action: To fix this and control telemetry, please remove the "
658+
"'enable_tracing' parameter from your deployment code.\n"
659+
"You can then use the "
660+
"'GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY' "
661+
"environment variable or the toggle in the Cloud Console: "
662+
"https://console.cloud.google.com/vertex-ai/agents."
663+
),
664+
)
665+
647666
enable_logging = bool(self._telemetry_enabled())
648667

649668
self._tmpl_attrs["instrumentor"] = _default_instrumentor_builder(

0 commit comments

Comments
 (0)