Skip to content

feat(Spanner)!: upgrade OpenTelemetry to v2 - #9329

Merged
alkatrivedi merged 12 commits into
mainfrom
support-otel-major-version
Sep 18, 2026
Merged

alkatrivedi merged 12 commits into
mainfrom
support-otel-major-version

Conversation

@alkatrivedi

@alkatrivedi alkatrivedi commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

This PR introduce OpenTelemetry SDK upgraded to v2
@google-cloud/spanner now 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-util removed (deprecated upstream; the single interface used, MonitoredResource, is now declared internally)
  • @opentelemetry/resource-detector-gcp ^0.57.0 added

@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 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.

Comment thread handwritten/spanner/src/metrics/constants.ts Outdated
Comment thread handwritten/spanner/src/metrics/constants.ts
@alkatrivedi
alkatrivedi force-pushed the support-otel-major-version branch from a2ba841 to 936f2e9 Compare September 15, 2026 06:07
@alkatrivedi alkatrivedi changed the title chore(Spanner)\!: upgrade OpenTelemetry to v2 chore(Spanner)!: upgrade OpenTelemetry to v2 Sep 15, 2026
@alkatrivedi
alkatrivedi force-pushed the support-otel-major-version branch 2 times, most recently from c4c35bc to 3c95b8b Compare September 16, 2026 07:09
@alkatrivedi
alkatrivedi marked this pull request as ready for review September 16, 2026 07:35
@alkatrivedi
alkatrivedi requested a review from a team as a code owner September 16, 2026 07:35
@github-actions
github-actions Bot requested a review from feywind September 16, 2026 07:35
@alkatrivedi
alkatrivedi force-pushed the support-otel-major-version branch 3 times, most recently from 52eb641 to 6078171 Compare September 16, 2026 09:35
@alkatrivedi
alkatrivedi requested a review from a team as a code owner September 16, 2026 10:35
@alkatrivedi
alkatrivedi force-pushed the support-otel-major-version branch 3 times, most recently from c1dc465 to facc8d7 Compare September 17, 2026 05:25
Comment thread handwritten/spanner/src/metrics/metrics-tracer-factory.ts
Comment thread handwritten/spanner/src/metrics/metrics-tracer-factory.ts
Comment thread handwritten/spanner/src/metrics/metrics-tracer-factory.ts
Comment thread handwritten/spanner/src/metrics/metrics-tracer-factory.ts Outdated
Comment thread handwritten/spanner/test/metrics/metrics-tracer-factory.ts
@alkatrivedi
alkatrivedi force-pushed the support-otel-major-version branch from 6f15e82 to 4eeab79 Compare September 17, 2026 16:33
@alkatrivedi
alkatrivedi force-pushed the support-otel-major-version branch from 4eeab79 to 01478f5 Compare September 17, 2026 16:36
@olavloite

Copy link
Copy Markdown
Contributor

/gemini review

@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 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.

Comment thread handwritten/spanner/src/metrics/constants.ts
Comment thread handwritten/spanner/src/metrics/constants.ts
Comment thread handwritten/spanner/src/metrics/metrics-tracer-factory.ts
Comment thread handwritten/spanner/OBSERVABILITY.md
Comment thread handwritten/spanner/src/metrics/metrics-tracer-factory.ts
…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.
@olavloite

Copy link
Copy Markdown
Contributor

/gemini review

@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 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.

Comment thread handwritten/spanner/src/metrics/metrics-tracer-factory.ts
Comment thread handwritten/spanner/src/index.ts
Comment thread handwritten/spanner/src/index.ts
alkatrivedi and others added 2 commits September 18, 2026 11:14
…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.
@alkatrivedi
alkatrivedi force-pushed the support-otel-major-version branch from 1a68f1c to 51b4fa9 Compare September 18, 2026 06:29
@olavloite

Copy link
Copy Markdown
Contributor

/gemini review

@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 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.

Comment thread handwritten/spanner/src/metrics/metrics-tracer-factory.ts
@olavloite olavloite changed the title chore(Spanner)!: upgrade OpenTelemetry to v2 feat(Spanner)!: upgrade OpenTelemetry to v2 Sep 18, 2026
@alkatrivedi
alkatrivedi merged commit ed3a44e into main Sep 18, 2026
50 checks passed
@alkatrivedi
alkatrivedi deleted the support-otel-major-version branch September 18, 2026 07:26
alkatrivedi pushed a commit that referenced this pull request Sep 18, 2026
🤖 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>
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.

2 participants