Skip to content

fix(bigtable): auto-disable built-in Cloud Monitoring on custom endpoints and unauthenticated clients - #15294

Open
igorbernstein2 wants to merge 1 commit into
mainfrom
fix/bigtable-metrics-endpoint-guard
Open

igorbernstein2 wants to merge 1 commit into
mainfrom
fix/bigtable-metrics-endpoint-guard

Conversation

@igorbernstein2

@igorbernstein2 igorbernstein2 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Behavior Change (Release Notes)

User-visible behavior change for regional (REP), named PSC, and Private/Restricted VIP endpoints: Previously, clients in googleapis.com configured with a regional endpoint (*.rep.googleapis.com), named Private Service Connect endpoint (*.p.googleapis.com), or private.googleapis.com / restricted.googleapis.com exported built-in Cloud Monitoring metrics to global monitoring.googleapis.com:443 by default. With this change, built-in Cloud Monitoring export is automatically disabled (with a WARNING log) for those endpoints unless a Cloud Monitoring endpoint is explicitly configured via setMetricsEndpoint(...).

Problem

  1. When a Bigtable client is configured with a non-standard data endpoint (such as a partner universe endpoint via setEndpoint("bigtable.<universe>:443") without setting universeDomain or GOOGLE_CLOUD_UNIVERSE_DOMAIN, a regional endpoint *.rep.<universe>, a named PSC endpoint *.p.<universe>, private.<universe> / restricted.<universe>, or a proxy/emulator endpoint) and no explicit metricsEndpoint, default-on built-in Cloud Monitoring export still uses the defaulted googleapis.com universe domain and dials monitoring.googleapis.com:443 with the client's credentials and telemetry.
  2. When a client is configured with NoCredentialsProvider (and no explicit metricsEndpoint or legacy metrics credential override), built-in Cloud Monitoring export still sends unauthenticated telemetry to monitoring.googleapis.com:443.

Solution

  • BigtableClientContext: Gate built-in Cloud Monitoring (builtinOtel) initialization on shouldEnableBuiltinMetrics(settings, credentials):
    1. Disabled silently when !settings.areInternalMetricsEnabled().
    2. Always enabled when an explicit settings.getMetricsEndpoint() or -Dbigtable.test-monitoring-endpoint override is set.
    3. Disabled (logged at FINE) when effective metrics credentials are null (NoCredentialsProvider) and no explicit metrics endpoint is set.
    4. Enabled only when settings.getEndpoint() is a valid port-443 (or omitted-port) subdomain of settings.getUniverseDomain(), excluding regional endpoints (*.rep.<universeDomain>), named PSC endpoints (*.p.<universeDomain>), and Private/Restricted Google Access VIPs (private.<universeDomain>, restricted.<universeDomain>). Otherwise, built-in Cloud Monitoring export is disabled with a targeted WARNING log:
      • Outside the configured universe: suggests configuring setUniverseDomain() / GOOGLE_CLOUD_UNIVERSE_DOMAIN or setMetricsEndpoint(...).
      • Inside the universe but REP / named PSC / private / restricted: explains default export is not supported for that endpoint type and suggests setMetricsEndpoint(...).
    • Note: settings.getEndpoint() reflects custom endpoints set on InstantiatingGrpcChannelProvider, but opaque TransportChannelProviders (e.g., FixedTransportChannelProvider wrapping a prebuilt channel) cannot be inspected and remain enabled.
    • Caller-owned CustomOpenTelemetryMetricsProvider (userOtel) is unaffected.
  • BigtableCloudMonitoringExporter: Expose @InternalApi getMonitoringEndpointOverride() and ignore blank endpoint overrides consistently.

Testing

  • Formatted with fmt-maven-plugin:format.
  • Expanded BigtableClientContextTest and BigtableCloudMonitoringExporter2Test in JUnit 5 covering same-universe subdomains, cross-universe/TPC, REP, named PSC, private/restricted (including targeted remediation warnings), malformed/non-443 endpoints, InstantiatingGrpcChannelProvider custom endpoints, NoCredentialsProvider, explicit metricsEndpoint, disableInternalMetrics(), toBuilder() re-evaluation, and CustomOpenTelemetryMetricsProvider isolation.

@igorbernstein2
igorbernstein2 requested review from a team as code owners November 30, 2026 20:20

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the initialization and enablement logic for built-in Cloud Monitoring metrics in the Bigtable client. It introduces helper methods to validate standard Bigtable endpoints and universe domains, ensuring built-in metrics are only enabled under appropriate configurations. Comprehensive unit tests are added to cover these edge cases. A review comment identifies a potential NullPointerException in MetricsImpl.java where a null check on userTracerFactory was omitted during refactoring.

@igorbernstein2
igorbernstein2 force-pushed the fix/bigtable-metrics-endpoint-guard branch 2 times, most recently from 6f66d7c to 42e9ab4 Compare November 30, 2026 22:40
@nimf

nimf commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

oh, also, AFAIK, release notes won't be picked up from PR description. If we need release notes for this, it has to be in a commit.

@igorbernstein2
igorbernstein2 force-pushed the fix/bigtable-metrics-endpoint-guard branch from 025fb15 to 4050867 Compare December 3, 2026 20:20
@igorbernstein2
igorbernstein2 enabled auto-merge (squash) December 3, 2026 20:57

This branch has not been deployed

No deployments
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.

3 participants