Skip to content

Commit 8bc0ed4

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 8bc0ed4

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,32 @@ 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 "
720+
"toggle and environment variable controls.\n"
721+
"Impact: The Cloud Console may incorrectly show telemetry "
722+
"as 'On' when it is actually 'Off', and the UI toggle will "
723+
"not work.\n"
724+
"Action: To fix this and control telemetry, please remove "
725+
"the 'enable_tracing' parameter from your deployment "
726+
"code.\n"
727+
"You can then use the "
728+
"'GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY' "
729+
"environment variable:\n"
730+
"agent_engines.create(\n"
731+
" env_vars={\n"
732+
' "GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY": true|false\n'
733+
" }\n"
734+
")\n"
735+
"or the toggle in the Cloud Console: "
736+
"https://console.cloud.google.com/vertex-ai/agents."
737+
),
738+
)
739+
714740
if custom_instrumentor and self._tracing_enabled():
715741
self._tmpl_attrs["instrumentor"] = custom_instrumentor(project)
716742

vertexai/preview/reasoning_engines/templates/adk.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,32 @@ 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 "
653+
"toggle and environment variable controls.\n"
654+
"Impact: The Cloud Console may incorrectly show telemetry "
655+
"as 'On' when it is actually 'Off', and the UI toggle will "
656+
"not work.\n"
657+
"Action: To fix this and control telemetry, please remove "
658+
"the 'enable_tracing' parameter from your deployment "
659+
"code.\n"
660+
"You can then use the "
661+
"'GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY' "
662+
"environment variable:\n"
663+
"agent_engines.create(\n"
664+
" env_vars={\n"
665+
' "GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY": true|false\n'
666+
" }\n"
667+
")\n"
668+
"or the toggle in the Cloud Console: "
669+
"https://console.cloud.google.com/vertex-ai/agents."
670+
),
671+
)
672+
647673
enable_logging = bool(self._telemetry_enabled())
648674

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

0 commit comments

Comments
 (0)