You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Updates the Google Cloud Trace integration guide to document telemetry attribute schemas, deployment privacy defaults, and payload redaction behaviors.
Clarifies architectural boundaries between the Agent Development Kit orchestration layer (ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS) and the model telemetry layer (OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT), detailing empty JSON placeholder redaction ("{}") to prevent accidental PII leakage in production.
Verified: When executing adk deploy agent_engine with --otel_to_cloud / --trace_to_cloud, ADK automatically sets ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS='false' in env_vars if not already specified in the user's environment configuration.
Verified: In the core Python runtime, TelemetryConfig.should_add_content_to_legacy_spans evaluates os.getenv(ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS, 'true'). Values in _FALSY_ENV_VALUES = frozenset({'0', 'false'}) disable payload population; all other values enable it.
Placeholder Replacement Behavior ("{}") on Redacted Payloads:
Verified: ContentCapturingMode supports NO_CONTENT, EVENT_ONLY, SPAN_ONLY, and SPAN_AND_EVENT.
Truthy values ('1', 'true') for OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT coerce to EVENT_ONLY (logging to LogRecord), whereas span-level capture requires SPAN_ONLY or SPAN_AND_EVENT together with OTEL_SEMCONV_STABILITY_OPT_IN='gen_ai_latest_experimental'.
Verified: Complete test assertions confirm that setting ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS='false' injects '{}' across test_call_llm_disabling_request_response_content, test_trace_tool_call_disabling_request_response_content, test_trace_merged_tool_disabling_request_response_content, and test_trace_send_data_disabling_request_response_content.
Verified every claim in this PR against google/adk-python @ 01919b3 (main HEAD at time of review). All citations below are permalinks pinned to that commit.
Verdict: substantially correct — one required fix.
Verified correct
All 9 attributes in the new table exist. The five newly documented payload attributes are written at tracing.py#L305-L309 (tool_call_args), #L335-L339 (tool_response), #L629-L633 (llm_request), #L660-L674 (llm_response), #L749-L758 (data). "Prompt text and configuration" for llm_request is precise — _build_llm_request_for_trace emits {model, config, contents} (#L815-L862).
'false' / '0' semantics — context.py#L107-L112 plus _FALSY_ENV_VALUES at #L54. Defaults on, consistent with the "explicitly set 'true'" framing.
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT='true'/'1' → events, not spans — coerced to EVENT_ONLY at context.py#L93-L104, which is "content on the emitted LogRecord only" (#L66). The PR's word choice ("events") is correct.
Required fix: "(or --trace_to_cloud)" is incorrect
For agent_engine that flag is deprecated and takes no part in this behavior:
Docstring: "trace_to_cloud (bool): Deprecated. This argument is no longer required or used." — cli_deploy.py#L1024-L1025
Passing it only emits a DeprecationWarning pointing at --otel_to_cloud — #L1210-L1216
The redaction block is guarded solely by if otel_to_cloud: — #L1273
The CLI option itself is labelled deprecated, with a _deprecate_trace_to_cloud callback — cli_tools_click.py#L2574-L2581
This was probably inherited from the stale CLI example higher up in the same file (docs/integrations/cloud-trace.md:122 still shows --trace_to_cloud), which is worth fixing in this PR too.
Worth tightening (non-blocking)
"automatically sets" omits the if unset condition — the guard is if 'ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS' not in env_vars: (cli_deploy.py#L1281). A value already in .env wins.
The default does not apply when telemetry is enabled via .env alone — GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY=true flips otel_to_cloud in the else branch, after the redaction block is skipped (#L1283-L1292). That route exports traces with content — a real PII footgun the doc currently implies is covered.
The default is agent_engine-only — ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS appears exactly once in src/google/adk/cli/. adk deploy cloud_run and adk deploy gke inject nothing.
Missing the per-request override and admin lock — RunConfig.telemetry=TelemetryConfig(capture_message_content=...) takes precedence, and setting it to anything (including EVENT_ONLY) bypasses the env var and turns legacy span content off (context.py#L260-L273). ADK_TELEMETRY_IGNORE_RUN_CONFIG=1 locks the policy against application code (#L193-L200) — arguably the most important control for a production-facing privacy section. Consider linking the canonical guide: docs/guides/telemetry/telemetry_config/index.md.
Nit: one span writes "N/A", not "{}" — trace_merged_tool_calls sets gcp.vertex.agent.tool_call_args to "N/A" unconditionally (tracing.py#L528-L531). "Placeholder values" would cover both cases.
Nit: gcp.vertex.agent.session_id is set but unlisted — written on call_llm spans alongside gen_ai.conversation.id (tracing.py#L624-L626). Users filtering in Trace Explorer will see it.
Suggested replacement for the first bullet
Deployment default: When you deploy with adk deploy agent_engine --otel_to_cloud, ADK sets ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS='false' for you, unless your .env already defines it. This default applies only to Agent Engine deployments made with this flag: adk deploy cloud_run, adk deploy gke, and enabling telemetry solely via GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY in .env do not apply it, and will export message content unless you set the variable yourself. The deprecated --trace_to_cloud flag has no effect on content capture — use --otel_to_cloud.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First draft of a pull request for Cloud Trace Data Capture.