Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tests/unit/vertex_adk/test_agent_engine_templates_adk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/vertex_adk/test_reasoning_engine_templates_adk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions vertexai/agent_engines/templates/adk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
26 changes: 26 additions & 0 deletions vertexai/preview/reasoning_engines/templates/adk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down