Repository navigation
Commit 493a254
authored
fix(bigtable): auto-disable built-in Cloud Monitoring on custom endpoints and unauthenticated clients (#15294)
## 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
`TransportChannelProvider`s (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.1 parent 3f117da commit 493a254
5 files changed
Lines changed: 889 additions & 21 deletions
File tree
- java-bigtable/google-cloud-bigtable
- src
- main/java/com/google/cloud/bigtable/data/v2
- internal/csm/exporter
- stub
- test/java/com/google/cloud/bigtable/data/v2
- internal/csm/exporter
- stub
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
357 | 362 | | |
358 | 363 | | |
359 | 364 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
91 | 107 | | |
92 | 108 | | |
93 | 109 | | |
| |||
107 | 123 | | |
108 | 124 | | |
109 | 125 | | |
110 | | - | |
| 126 | + | |
| 127 | + | |
111 | 128 | | |
112 | 129 | | |
113 | 130 | | |
114 | | - | |
| 131 | + | |
115 | 132 | | |
116 | 133 | | |
117 | | - | |
118 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
119 | 137 | | |
120 | 138 | | |
121 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| 41 | + | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| |||
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| 50 | + | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
| |||
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
| 62 | + | |
| 63 | + | |
58 | 64 | | |
59 | 65 | | |
60 | 66 | | |
| 67 | + | |
61 | 68 | | |
62 | 69 | | |
63 | 70 | | |
| |||
155 | 162 | | |
156 | 163 | | |
157 | 164 | | |
158 | | - | |
| 165 | + | |
159 | 166 | | |
160 | 167 | | |
161 | 168 | | |
| |||
249 | 256 | | |
250 | 257 | | |
251 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
252 | 381 | | |
253 | 382 | | |
254 | 383 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| 55 | + | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
| |||
505 | 507 | | |
506 | 508 | | |
507 | 509 | | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
508 | 532 | | |
509 | 533 | | |
510 | 534 | | |
| |||
0 commit comments