feat(Spanner)!: upgrade OpenTelemetry to v2 - #9329
Conversation
There was a problem hiding this comment.
Code Review
This pull request upgrades OpenTelemetry dependencies to v2, removes the deprecated @google-cloud/opentelemetry-resource-util package in favor of @opentelemetry/resource-detector-gcp, and migrates Resource instantiations to resourceFromAttributes. However, the changes to metric views in constants.ts incorrectly use plain ViewOptions instead of instantiating View classes, which will cause runtime or compilation errors. The feedback correctly advises importing Aggregation and View and instantiating the views properly using Aggregation.ExplicitBucketHistogram.
a2ba841 to
936f2e9
Compare
c4c35bc to
3c95b8b
Compare
52eb641 to
6078171
Compare
c1dc465 to
facc8d7
Compare
6f15e82 to
4eeab79
Compare
4eeab79 to
01478f5
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request upgrades the OpenTelemetry SDK dependencies to v2-compatible releases, refactors resource creation to use resourceFromAttributes, and updates MetricsTracerFactory to support asynchronous location detection and dynamic MeterProvider recreation. Feedback on these changes highlights several critical issues: in constants.ts, passing plain ViewOptions instead of instantiating View classes and using the non-existent AggregationType.EXPLICIT_BUCKET_HISTOGRAM will cause compilation errors; in metrics-tracer-factory.ts, passing a Promise object (_locationPromise) as a resource attribute violates the OpenTelemetry specification and will cause serialization failures, while recreating the MeterProvider at runtime risks losing metrics for active tracers; and in OBSERVABILITY.md, the example code snippet is missing the import for TraceIdRatioBasedSampler.
…ments Fixes metric exporter hang on shutdown when throttled, prevents context leak in periodic reader interval, avoids duplicate MetricReader warnings with multiple clients, and guards MetricsTracerFactory against ADC placeholder project IDs. Adds corresponding zero-sleep unit tests.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request upgrades OpenTelemetry dependencies to v2-compatible releases, refactors metrics initialization, and migrates from the deprecated @google-cloud/opentelemetry-resource-util to @opentelemetry/resource-detector-gcp for location detection. Feedback on these changes highlights a type violation in metrics-tracer-factory.ts where a Promise is passed to resourceFromAttributes instead of a string. Additionally, the reviewer recommends replacing the hardcoded instantiations of InstanceAdminClient and DatabaseAdminClient in src/index.ts with dynamic lookups to prevent potential runtime bugs and maintain consistency with other clients.
…ments Fixes metric exporter hang on shutdown when throttled, prevents context leak in periodic reader interval, avoids duplicate MetricReader warnings with multiple clients, and guards MetricsTracerFactory against ADC placeholder project IDs. Adds corresponding zero-sleep unit tests.
1a68f1c to
51b4fa9
Compare
…ogle-cloud-node into support-otel-major-version
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request upgrades OpenTelemetry dependencies to v2-compatible releases, replacing the deprecated Resource class with resourceFromAttributes and migrating from @google-cloud/opentelemetry-resource-util to @opentelemetry/resource-detector-gcp. It also enhances location detection, async attribute handling, and MeterProvider initialization. Feedback points out a high-severity issue where recreating the MeterProvider leaves cached MetricsTracer instances holding references to shut-down metric instruments, and suggests clearing the cached tracers during recreation to prevent silent failures.
🤖 I have created a release *beep* *boop* --- ## [9.0.0](spanner-v8.13.0...spanner-v9.0.0) (2026-09-18) ### ⚠ BREAKING CHANGES * **Spanner:** Update cloud-spanner to minimum Node version of 22 ([#9291](#9291)) * **Spanner:** upgrade OpenTelemetry to v2 ([#9329](#9329)) ### Features * **Spanner:** Update cloud-spanner to minimum Node version of 22 ([#9291](#9291)) ([ecd5bfd](ecd5bfd)) * **Spanner:** Upgrade OpenTelemetry to v2 ([#9329](#9329)) ([ed3a44e](ed3a44e)) ### Performance Improvements * **spanner:** Bypass gRPC message interception in metrics interceptor ([#9306](#9306)) ([a44180d](a44180d)) * **spanner:** Disable gRPC channelz by default ([#9320](#9320)) ([11c257b](11c257b)) * **spanner:** Optimize codec.getType and reuse type singletons ([#9366](#9366)) ([1b1b411](1b1b411)) * **spanner:** Remove rest-parameter allocations in wrappedRequestFn ([#9365](#9365)) ([7085e03](7085e03)) * **spanner:** Synchronous multiplexed session hand-off for non-stream callers ([#9362](#9362)) ([dbbc55c](dbbc55c)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
This PR introduce OpenTelemetry SDK upgraded to v2
@google-cloud/spannernow depends on the OpenTelemetry JS v2 SDK:@opentelemetry/sdk-metrics^1.30.1 → ^2.11.0@opentelemetry/resources^1.8.0 → ^2.11.0@google-cloud/opentelemetry-resource-utilremoved (deprecated upstream; the single interface used, MonitoredResource, is now declared internally)@opentelemetry/resource-detector-gcp^0.57.0 added