Repository navigation
fix(spanner): disable default built-in metrics for non-standard endpoints and custom channel providers - #15272
Merged
sakthivelmanii merged 2 commits intoDec 1, 2026
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the logic in SpannerOptions to determine when built-in Cloud Monitoring metrics should be enabled. It introduces a more robust resolution mechanism that automatically disables built-in metrics when non-standard endpoints or custom channel providers are configured, unless an explicit monitoring host is specified. This prevents potential telemetry or credential leaks. The changes also update the README documentation and add extensive unit tests to validate these behaviors. No review comments were provided, so there is no feedback to address.
sakthivelmanii
force-pushed
the
fix/spanner-builtin-metrics-custom-channel-provider
branch
from
November 30, 2026 19:56
d76f99a to
52ec3aa
Compare
olavloite
approved these changes
Dec 1, 2026
sakthivelmanii
enabled auto-merge (squash)
December 1, 2026 14:52
…ints and custom channel providers - Default-on built-in Cloud Monitoring metrics could still attempt to export telemetry and credentials to `monitoring.googleapis.com` when a client configured a custom `TransportChannelProvider` (such as an `InstantiatingGrpcChannelProvider` with a custom endpoint or an opaque provider) or a non-standard `setHost(...)` endpoint (including regional, private/restricted, non-443, or non-HTTPS endpoints) without an explicit `monitoringHost`. - Automatically disable default-on built-in Cloud Monitoring metrics unless the effective Spanner endpoint matches the standard endpoint for the resolved universe domain (`spanner.<universeDomain>:443` for `InstantiatingGrpcChannelProvider`, or `https://spanner.<universeDomain>[:443]` for `setHost(...)`), or `monitoringHost` (`SpannerOptions.Builder.setMonitoringHost(...)` / `SPANNER_MONITORING_HOST`) is explicitly configured. - Mirror runtime channel selection precedence: an opaque `TransportChannelProvider` or an `InstantiatingGrpcChannelProvider` with an explicit endpoint takes precedence over `setHost(...)`; an endpoint-less `InstantiatingGrpcChannelProvider` falls back to `setHost(...)`. - Suppress the auto-disable warning log when plaintext or `NoCredentials` are configured. - Document the unified endpoint and custom channel provider behavior in `SpannerOptions.isEnableBuiltInMetrics()` Javadoc and the Spanner README. - `setHost(...)` with regional (`*.rep.googleapis.com`), `private.googleapis.com`, `restricted.googleapis.com`, non-443, or non-HTTPS endpoints now auto-disables built-in Cloud Monitoring metrics unless `monitoringHost` / `SPANNER_MONITORING_HOST` is explicitly set. - `setHost(...)` combined with `setUniverseDomain(...)` keeps built-in Cloud Monitoring metrics enabled only when the host matches `https://spanner.<universeDomain>[:443]`. - Auto-disable `WARNING` logs are also suppressed when `NoCredentials` (or null credentials) are configured.
sakthivelmanii
force-pushed
the
fix/spanner-builtin-metrics-custom-channel-provider
branch
from
December 1, 2026 15:24
3cc68bc to
49384e2
Compare
sakthivelmanii
disabled auto-merge
December 1, 2026 15:27
sakthivelmanii
enabled auto-merge (squash)
December 1, 2026 15:27
sakthivelmanii
deleted the
fix/spanner-builtin-metrics-custom-channel-provider
branch
December 1, 2026 15:55
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.
Problem Statement
monitoring.googleapis.comwhen a client configured a customTransportChannelProvider(such as anInstantiatingGrpcChannelProviderwith a custom endpoint or an opaque provider) or a non-standardsetHost(...)endpoint (including regional, private/restricted, non-443, or non-HTTPS endpoints) without an explicitmonitoringHost.Solution
spanner.<universeDomain>:443forInstantiatingGrpcChannelProvider, orhttps://spanner.<universeDomain>[:443]forsetHost(...)), ormonitoringHost(SpannerOptions.Builder.setMonitoringHost(...)/SPANNER_MONITORING_HOST) is explicitly configured.TransportChannelProvideror anInstantiatingGrpcChannelProviderwith an explicit endpoint takes precedence oversetHost(...); an endpoint-lessInstantiatingGrpcChannelProviderfalls back tosetHost(...).NoCredentialsare configured.SpannerOptions.isEnableBuiltInMetrics()Javadoc and the Spanner README.Behavior Changes
setHost(...)with regional (*.rep.googleapis.com),private.googleapis.com,restricted.googleapis.com, non-443, or non-HTTPS endpoints now auto-disables built-in Cloud Monitoring metrics unlessmonitoringHost/SPANNER_MONITORING_HOSTis explicitly set.setHost(...)combined withsetUniverseDomain(...)keeps built-in Cloud Monitoring metrics enabled only when the host matcheshttps://spanner.<universeDomain>[:443].WARNINGlogs are also suppressed whenNoCredentials(or null credentials) are configured.