diff --git a/tests/unit/vertex_adk/test_agent_engine_templates_adk.py b/tests/unit/vertex_adk/test_agent_engine_templates_adk.py index 980e985433..19fb6c79d4 100644 --- a/tests/unit/vertex_adk/test_agent_engine_templates_adk.py +++ b/tests/unit/vertex_adk/test_agent_engine_templates_adk.py @@ -800,6 +800,22 @@ def test_enable_tracing_warning(self, caplog): # app.set_up() # assert "enable_tracing=True but proceeding with tracing disabled" in caplog.text + # TODO(b/384730642): Re-enable this test once the parent issue is fixed. + # @pytest.mark.parametrize( + # "enable_tracing,want_warning", + # [ + # (True, False), + # (False, True), + # (None, False), + # ], + # ) + # @pytest.mark.usefixtures("caplog") + # def test_tracing_disabled_warning(self, enable_tracing, want_warning, caplog): + # _ = agent_engines.AdkApp(agent=_TEST_AGENT, enable_tracing=enable_tracing) + # assert ( + # "[WARNING] Your 'enable_tracing=False' setting" in caplog.text + # ) == want_warning + @mock.patch.dict(os.environ) def test_span_content_capture_disabled_by_default(self): app = agent_engines.AdkApp(agent=_TEST_AGENT) diff --git a/tests/unit/vertex_adk/test_reasoning_engine_templates_adk.py b/tests/unit/vertex_adk/test_reasoning_engine_templates_adk.py index 917b9430d1..add706859a 100644 --- a/tests/unit/vertex_adk/test_reasoning_engine_templates_adk.py +++ b/tests/unit/vertex_adk/test_reasoning_engine_templates_adk.py @@ -781,6 +781,25 @@ def test_enable_tracing_warning(self, caplog): # app.set_up() # assert "enable_tracing=True but proceeding with tracing disabled" in caplog.text + # TODO(b/384730642): Re-enable this test once the parent issue is fixed. + # @pytest.mark.parametrize( + # "enable_tracing,want_warning", + # [ + # (True, False), + # (False, True), + # (None, False), + # ], + # ) + # @pytest.mark.usefixtures("caplog") + # def test_tracing_disabled_warning(self, enable_tracing, want_warning, caplog): + # app = reasoning_engines.AdkApp( + # agent=Agent(name=_TEST_AGENT_NAME, model=_TEST_MODEL), + # enable_tracing=enable_tracing + # ) + # assert ( + # "[WARNING] Your 'enable_tracing=False' setting" in caplog.text + # ) == want_warning + def test_dump_event_for_json(): from google.adk.events import event diff --git a/vertexai/agent_engines/templates/adk.py b/vertexai/agent_engines/templates/adk.py index db1b1ff423..4176b58e4a 100644 --- a/vertexai/agent_engines/templates/adk.py +++ b/vertexai/agent_engines/templates/adk.py @@ -724,6 +724,32 @@ def set_up(self): custom_instrumentor = self._tmpl_attrs.get("instrumentor_builder") + if self._tmpl_attrs.get("enable_tracing") is False: + _warn( + ( + "Your 'enable_tracing=False' setting is being deprecated " + "and will be removed in a future release.\n" + "This legacy setting overrides the new Cloud Console " + "toggle and environment variable controls.\n" + "Impact: The Cloud Console may incorrectly show telemetry " + "as 'On' when it is actually 'Off', and the UI toggle will " + "not work.\n" + "Action: To fix this and control telemetry, please remove " + "the 'enable_tracing' parameter from your deployment " + "code.\n" + "You can then use the " + "'GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY' " + "environment variable:\n" + "agent_engines.create(\n" + " env_vars={\n" + ' "GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY": true|false\n' + " }\n" + ")\n" + "or the toggle in the Cloud Console: " + "https://console.cloud.google.com/vertex-ai/agents." + ), + ) + if custom_instrumentor and self._tracing_enabled(): self._tmpl_attrs["instrumentor"] = custom_instrumentor(project) diff --git a/vertexai/preview/reasoning_engines/templates/adk.py b/vertexai/preview/reasoning_engines/templates/adk.py index eefe01ed53..8b49b992c6 100644 --- a/vertexai/preview/reasoning_engines/templates/adk.py +++ b/vertexai/preview/reasoning_engines/templates/adk.py @@ -657,6 +657,32 @@ def set_up(self): else: os.environ["ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS"] = "false" + if self._tmpl_attrs.get("enable_tracing") is False: + _warn( + ( + "Your 'enable_tracing=False' setting is being deprecated " + "and will be removed in a future release.\n" + "This legacy setting overrides the new Cloud Console " + "toggle and environment variable controls.\n" + "Impact: The Cloud Console may incorrectly show telemetry " + "as 'On' when it is actually 'Off', and the UI toggle will " + "not work.\n" + "Action: To fix this and control telemetry, please remove " + "the 'enable_tracing' parameter from your deployment " + "code.\n" + "You can then use the " + "'GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY' " + "environment variable:\n" + "agent_engines.create(\n" + " env_vars={\n" + ' "GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY": true|false\n' + " }\n" + ")\n" + "or the toggle in the Cloud Console: " + "https://console.cloud.google.com/vertex-ai/agents." + ), + ) + enable_logging = bool(self._telemetry_enabled()) self._tmpl_attrs["instrumentor"] = _default_instrumentor_builder(