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
{{ message }}
Repository navigation
Commit 2c52d5e
Browse filesBrowse the repository at this point in the historyBrowse files
fix(spanner): disable built-in Cloud Monitoring metrics for custom non-default hosts without an explicit target (#15252)
## Problem Statement
- When configuring a custom non-`*.googleapis.com` Spanner host via
`SpannerOptions.Builder.setHost(...)` or a JDBC/Connection URL host or
`endpoint` property without setting `universeDomain`,
`GOOGLE_CLOUD_UNIVERSE_DOMAIN`, `monitoringHost`, or
`SPANNER_MONITORING_HOST`, default-on built-in Cloud Monitoring metrics
remained enabled and exported telemetry and credentials to
`monitoring.googleapis.com:443`.
## Solution
- Automatically disable built-in Cloud Monitoring metrics when a custom
non-`*.googleapis.com` host (including malformed or scheme-less hosts)
is configured without an explicit `universeDomain`,
`GOOGLE_CLOUD_UNIVERSE_DOMAIN`, `monitoringHost`, or
`SPANNER_MONITORING_HOST`, logging a warning for non-plaintext,
non-emulator clients.
- Preserve `toBuilder()` re-evaluation when a caller later sets a
universe domain, sets a monitoring host, or clears the custom host, and
leave caller-owned `CustomOpenTelemetryMetricsProvider` sinks
unaffected.
Copy file name to clipboardExpand all lines: java-spanner/.readme-partials.yaml
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,8 @@ custom_content: |
67
67
68
68
You can also disable the default Cloud Monitoring export by setting `SPANNER_DISABLE_BUILTIN_METRICS` to `true`. These controls affect only the Cloud Monitoring export. They do not affect a caller-owned client-metrics export configured with `CustomOpenTelemetryMetricsProvider`.
69
69
70
+
When a custom non-`*.googleapis.com` host is configured via `SpannerOptions.Builder.setHost(...)` (or a JDBC/Connection URL host or `endpoint` property) without setting `setUniverseDomain(...)`, `GOOGLE_CLOUD_UNIVERSE_DOMAIN`, `setMonitoringHost(...)`, or `SPANNER_MONITORING_HOST`, the default Cloud Monitoring export is automatically disabled so telemetry and credentials are not sent to `monitoring.googleapis.com`.
71
+
70
72
> Note: Client-side metrics needs `monitoring.timeSeries.create` IAM permission to export metrics data to Cloud Monitoring. Ask your administrator to grant your service account the [Monitoring Metric Writer](https://cloud.google.com/iam/docs/roles-permissions/monitoring#monitoring.metricWriter) (roles/monitoring.metricWriter) IAM role on the project.
You can also disable the default Cloud Monitoring export by setting `SPANNER_DISABLE_BUILTIN_METRICS` to `true`. These controls affect only the Cloud Monitoring export. They do not affect a caller-owned client-metrics export configured with `CustomOpenTelemetryMetricsProvider`.
167
167
168
+
When a custom non-`*.googleapis.com` host is configured via `SpannerOptions.Builder.setHost(...)` (or a JDBC/Connection URL host or `endpoint` property) without setting `setUniverseDomain(...)`, `GOOGLE_CLOUD_UNIVERSE_DOMAIN`, `setMonitoringHost(...)`, or `SPANNER_MONITORING_HOST`, the default Cloud Monitoring export is automatically disabled so telemetry and credentials are not sent to `monitoring.googleapis.com`.
169
+
168
170
> Note: Client-side metrics needs `monitoring.timeSeries.create` IAM permission to export metrics data to Cloud Monitoring. Ask your administrator to grant your service account the [Monitoring Metric Writer](https://cloud.google.com/iam/docs/roles-permissions/monitoring#monitoring.metricWriter) (roles/monitoring.metricWriter) IAM role on the project.
Copy file name to clipboardExpand all lines: java-spanner/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BuiltInMetricsCustomOpenTelemetryTest.java
+80-17Lines changed: 80 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -177,31 +177,87 @@ public boolean isEnableGRPCBuiltInMetrics() {
177
177
});
178
178
BuiltInMetricsProvider.INSTANCE.reset();
179
179
180
-
// Default provider with NoCredentials and built-in metrics enabled must not initialize GCM.
181
-
try (SpannerdefaultSpanner =
182
-
spannerBuilder(DefaultMetricsProvider.INSTANCE)
183
-
.setEmulatorHost(null)
184
-
.setBuiltInMetricsEnabled(true)
185
-
.build()
186
-
.getService()) {
187
-
executeSelect1(defaultSpanner);
180
+
try {
181
+
// Default provider with NoCredentials and built-in metrics enabled must not initialize GCM.
Copy file name to clipboardExpand all lines: java-spanner/google-cloud-spanner/src/test/java/com/google/cloud/spanner/ChannelPoolBuiltInMetricsTest.java
0 commit comments