Skip to content

fix(telemetry): warn on invalid env values - #8440

Open
feiiiiii5 wants to merge 1 commit into
google:mainfrom
feiiiiii5:fix/8432-telemetry-warnings
Open

feiiiiii5 wants to merge 1 commit into
google:mainfrom
feiiiiii5:fix/8432-telemetry-warnings

Conversation

@feiiiiii5

Copy link
Copy Markdown
Contributor

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

Problem:

Unrecognized values of ADK_TELEMETRY_SCHEMA_VERSION_OPT_IN and OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT are silently discarded. A typo is indistinguishable from telemetry that was never enabled.

Solution:

Apply the bounded-warning shape already used by _normalize_experimental_features() to both readers. One helper reuses the existing _warnings_cache (deque(maxlen=64)), keyed by env var=value, and reports the rejected value, fallback, and accepted set. No fallback changes: 1/true still coerces to EVENT_ONLY, empty values stay silent, and documented schema aliases stay silent. No new cache, client, connection, loop, timer, or retained state.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

pytest -q tests/unittests/telemetry/test_telemetry_context.py tests/unittests/telemetry/test_schema_version.py — 212 passed, 11 pre-existing deprecation warnings. Three new warning cases fail on base source; they cover rejected value, fallback, accepted set, once-per-value deduplication, legacy coercion, empty values, and documented schema aliases. ruff check, pyink --check, isort --check-only, and git diff --check pass.

Manual End-to-End (E2E) Tests:

Set ADK_TELEMETRY_SCHEMA_VERSION_OPT_IN=v1 and OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=SPAN_AND_EVENTS, enable WARNING logging, and construct TelemetryConfig(). No model, credential, or network call is needed. Output:

WARNING google_adk.google.adk.telemetry.context: Ignoring invalid OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT value 'SPAN_AND_EVENTS'; falling back to NO_CONTENT. Accepted values: NO_CONTENT, EVENT_ONLY, SPAN_ONLY, SPAN_AND_EVENT; legacy 1/true.
WARNING google_adk.google.adk.telemetry.context: Ignoring invalid ADK_TELEMETRY_SCHEMA_VERSION_OPT_IN value 'v1'; falling back to 2 (semconv aligned). Accepted values: 1, 2, otel_semconv_1_36, otel_semconv_1_44.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules. (None.)

Additional context

Full tox matrix not run locally: this checkout has no uv.lock, and the uv-venv-lock-runner tox plugin is unavailable. The available CPython 3.14 environment ran the same telemetry tests directly.

🤖 Generated with Claude Code

Reuse the bounded warning cache to report rejected telemetry env values
without changing any resolution or fallback.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@google-cla

google-cla Bot commented Nov 29, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unrecognized values of two telemetry env vars are discarded without a warning

1 participant