feat: Add OpenTelemetry environment variable and options configuration helpers.#17524
Draft
chalmerlowe wants to merge 8 commits into
Draft
feat: Add OpenTelemetry environment variable and options configuration helpers.#17524chalmerlowe wants to merge 8 commits into
chalmerlowe wants to merge 8 commits into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces observability environment variable and client options resolution helpers under a new observability module, including the is_signal_enabled function and corresponding unit tests. Feedback is provided to improve the resolution of client options by avoiding direct __dict__ access (which fails for classes using __slots__ or properties) in favor of getattr, and replacing rstrip('s') with a safer suffix removal method to prevent unintended character stripping.
chalmerlowe
commented
Jun 22, 2026
brunoprado-ux
approved these changes
Jun 24, 2026
The assert statement was incorrectly indented inside the pytest.raises context manager, causing it to never execute. Dedented the assert to ensure exception messages are actually verified, which also resolves coverage gaps.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR introduces a foundational configuration layer for integrating OpenTelemetry (OTel) observability into Google Cloud Python client libraries. It establishes the
google.api_core.observabilitymodule, which is responsible for resolving telemetry configuration settings in a standardized, hierarchical manner (and ultimately enabling traces, metrics, and logs).Intent & Motivation
To provide a consistent observability experience across all Google Cloud Python clients, we are standardizing how telemetry signals (traces, metrics, logs) are enabled or disabled. This module parses and resolves configuration from multiple sources, falling back gracefully, so that users can control telemetry globally or on a per-service basis.
Changes Included
is_signal_enabledfunction in the newobservabilitypackage to resolve telemetry enablement settings based on a precedence hierarchy:Resolves settings in the following order of precedence:
1. Programmatic overrides in client_options (checks tracer_provider)
2. Language-wide Environment Variable: GOOGLE_CLOUD_PYTHON_TRACING_ENABLED
(natively checks for an EXPERIMENTAL prefix variant first)
3. Default fallback
Experimental Fallbacks: Implemented fallback logic that automatically checks for
EXPERIMENTALprefixes within the environment variable definitions to support early-stage adoption and rollout phases safely.Test Coverage: Provided test coverage using
pytestfor precedence rules and environmental scenarios.