Skip to content

Commit 7d18e72

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
chore: add warning to ADK deployment if tracing is disabled.
PiperOrigin-RevId: 827604495
1 parent a917122 commit 7d18e72

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
@@ -800,6 +800,22 @@ def test_enable_tracing_warning(self, caplog):
800800
# app.set_up()
801801
# assert "enable_tracing=True but proceeding with tracing disabled" in caplog.text
802802

803+
# TODO(b/384730642): Re-enable this test once the parent issue is fixed.
804+
# @pytest.mark.parametrize(
805+
# "enable_tracing,want_warning",
806+
# [
807+
# (True, False),
808+
# (False, True),
809+
# (None, False),
810+
# ],
811+
# )
812+
# @pytest.mark.usefixtures("caplog")
813+
# def test_tracing_disabled_warning(self, enable_tracing, want_warning, caplog):
814+
# _ = agent_engines.AdkApp(agent=_TEST_AGENT, enable_tracing=enable_tracing)
815+
# assert (
816+
# "[WARNING] Your 'enable_tracing=False' setting" in caplog.text
817+
# ) == want_warning
818+
803819
@mock.patch.dict(os.environ)
804820
def test_span_content_capture_disabled_by_default(self):
805821
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
@@ -781,6 +781,25 @@ def test_enable_tracing_warning(self, caplog):
781781
# app.set_up()
782782
# assert "enable_tracing=True but proceeding with tracing disabled" in caplog.text
783783

784+
# TODO(b/384730642): Re-enable this test once the parent issue is fixed.
785+
# @pytest.mark.parametrize(
786+
# "enable_tracing,want_warning",
787+
# [
788+
# (True, False),
789+
# (False, True),
790+
# (None, False),
791+
# ],
792+
# )
793+
# @pytest.mark.usefixtures("caplog")
794+
# def test_tracing_disabled_warning(self, enable_tracing, want_warning, caplog):
795+
# app = reasoning_engines.AdkApp(
796+
# agent=Agent(name=_TEST_AGENT_NAME, model=_TEST_MODEL),
797+
# enable_tracing=enable_tracing
798+
# )
799+
# assert (
800+
# "[WARNING] Your 'enable_tracing=False' setting" in caplog.text
801+
# ) == want_warning
802+
784803

785804
def test_dump_event_for_json():
786805
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
@@ -724,6 +724,32 @@ def set_up(self):
724724

725725
custom_instrumentor = self._tmpl_attrs.get("instrumentor_builder")
726726

727+
if self._tmpl_attrs.get("enable_tracing") is False:
728+
_warn(
729+
(
730+
"Your 'enable_tracing=False' setting is being deprecated "
731+
"and will be removed in a future release.\n"
732+
"This legacy setting overrides the new Cloud Console "
733+
"toggle and environment variable controls.\n"
734+
"Impact: The Cloud Console may incorrectly show telemetry "
735+
"as 'On' when it is actually 'Off', and the UI toggle will "
736+
"not work.\n"
737+
"Action: To fix this and control telemetry, please remove "
738+
"the 'enable_tracing' parameter from your deployment "
739+
"code.\n"
740+
"You can then use the "
741+
"'GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY' "
742+
"environment variable:\n"
743+
"agent_engines.create(\n"
744+
" env_vars={\n"
745+
' "GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY": true|false\n'
746+
" }\n"
747+
")\n"
748+
"or the toggle in the Cloud Console: "
749+
"https://console.cloud.google.com/vertex-ai/agents."
750+
),
751+
)
752+
727753
if custom_instrumentor and self._tracing_enabled():
728754
self._tmpl_attrs["instrumentor"] = custom_instrumentor(project)
729755

vertexai/preview/reasoning_engines/templates/adk.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,32 @@ def set_up(self):
657657
else:
658658
os.environ["ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS"] = "false"
659659

660+
if self._tmpl_attrs.get("enable_tracing") is False:
661+
_warn(
662+
(
663+
"Your 'enable_tracing=False' setting is being deprecated "
664+
"and will be removed in a future release.\n"
665+
"This legacy setting overrides the new Cloud Console "
666+
"toggle and environment variable controls.\n"
667+
"Impact: The Cloud Console may incorrectly show telemetry "
668+
"as 'On' when it is actually 'Off', and the UI toggle will "
669+
"not work.\n"
670+
"Action: To fix this and control telemetry, please remove "
671+
"the 'enable_tracing' parameter from your deployment "
672+
"code.\n"
673+
"You can then use the "
674+
"'GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY' "
675+
"environment variable:\n"
676+
"agent_engines.create(\n"
677+
" env_vars={\n"
678+
' "GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY": true|false\n'
679+
" }\n"
680+
")\n"
681+
"or the toggle in the Cloud Console: "
682+
"https://console.cloud.google.com/vertex-ai/agents."
683+
),
684+
)
685+
660686
enable_logging = bool(self._telemetry_enabled())
661687

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

0 commit comments

Comments
 (0)