Skip to content

feat!: Update cloud-spanner to minimum Node version of 22 - #9291

Open
alkatrivedi wants to merge 1 commit into
mainfrom
node-version-upgrade-22
Open

feat!: Update cloud-spanner to minimum Node version of 22#9291
alkatrivedi wants to merge 1 commit into
mainfrom
node-version-upgrade-22

Conversation

@alkatrivedi

@alkatrivedi alkatrivedi commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Upgrade the Node version from 18 to 22.

#8985

The PR also contains the OpenTelemetry package upgradation to v2 as part of this customer request.

@alkatrivedi
alkatrivedi requested a review from a team as a code owner September 11, 2026 14:32

@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, bumps the Node engine requirement to >=22, removes the deprecated @google-cloud/opentelemetry-resource-util package in favor of @opentelemetry/resource-detector-gcp and a local MonitoredResource interface, and updates metric view configurations and resource instantiations. The reviewer pointed out that in OpenTelemetry JS SDK v2, View and Aggregation are still classes rather than plain objects/options, and suggested reverting the plain object view configurations back to using new View and Aggregation.ExplicitBucketHistogram to prevent TypeScript compilation and runtime errors.

View,
ExplicitBucketHistogramAggregation,
} from '@opentelemetry/sdk-metrics';
import {AggregationType, ViewOptions} from '@opentelemetry/sdk-metrics';

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.

high

In OpenTelemetry JS SDK v2, View is still a class and MeterProvider expects an array of View instances rather than ViewOptions plain objects. Additionally, Aggregation is an abstract class, so plain objects cannot be assigned to it.

Please import View and Aggregation to define the views and aggregations properly.

Suggested change
import {AggregationType, ViewOptions} from '@opentelemetry/sdk-metrics';
import {Aggregation, View} from '@opentelemetry/sdk-metrics';

Comment on lines +91 to +114
const HISTOGRAM_AGGREGATION = {
type: AggregationType.EXPLICIT_BUCKET_HISTOGRAM as const,
options: {boundaries: HISTOGRAM_BUCKET_BOUNDARIES},
};

export const OPERATION_LATENCY_VIEW: ViewOptions = {
instrumentName: METRIC_NAME_OPERATION_LATENCIES,
aggregation: new ExplicitBucketHistogramAggregation(
HISTOGRAM_BUCKET_BOUNDARIES,
),
});
aggregation: HISTOGRAM_AGGREGATION,
};

export const ATTEMPT_LATENCY_VIEW = new View({
export const ATTEMPT_LATENCY_VIEW: ViewOptions = {
instrumentName: METRIC_NAME_ATTEMPT_LATENCIES,
aggregation: new ExplicitBucketHistogramAggregation(
HISTOGRAM_BUCKET_BOUNDARIES,
),
});
aggregation: HISTOGRAM_AGGREGATION,
};

export const GFE_LATENCY_VIEW = new View({
export const GFE_LATENCY_VIEW: ViewOptions = {
instrumentName: METRIC_NAME_GFE_LATENCIES,
aggregation: new ExplicitBucketHistogramAggregation(
HISTOGRAM_BUCKET_BOUNDARIES,
),
});
aggregation: HISTOGRAM_AGGREGATION,
};

export const AFE_LATENCY_VIEW = new View({
export const AFE_LATENCY_VIEW: ViewOptions = {
instrumentName: METRIC_NAME_AFE_LATENCIES,
aggregation: new ExplicitBucketHistogramAggregation(
HISTOGRAM_BUCKET_BOUNDARIES,
),
});
aggregation: HISTOGRAM_AGGREGATION,
};

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.

high

In OpenTelemetry JS SDK v2, Aggregation is an abstract class and cannot be represented as a plain object. Instead, use the static factory method Aggregation.ExplicitBucketHistogram(boundaries) to create the aggregation instance, and instantiate the views using new View(...).

This avoids TypeScript compilation errors and potential runtime failures since MeterProvider expects actual View and Aggregation instances.

Suggested change
const HISTOGRAM_AGGREGATION = {
type: AggregationType.EXPLICIT_BUCKET_HISTOGRAM as const,
options: {boundaries: HISTOGRAM_BUCKET_BOUNDARIES},
};
export const OPERATION_LATENCY_VIEW: ViewOptions = {
instrumentName: METRIC_NAME_OPERATION_LATENCIES,
aggregation: new ExplicitBucketHistogramAggregation(
HISTOGRAM_BUCKET_BOUNDARIES,
),
});
aggregation: HISTOGRAM_AGGREGATION,
};
export const ATTEMPT_LATENCY_VIEW = new View({
export const ATTEMPT_LATENCY_VIEW: ViewOptions = {
instrumentName: METRIC_NAME_ATTEMPT_LATENCIES,
aggregation: new ExplicitBucketHistogramAggregation(
HISTOGRAM_BUCKET_BOUNDARIES,
),
});
aggregation: HISTOGRAM_AGGREGATION,
};
export const GFE_LATENCY_VIEW = new View({
export const GFE_LATENCY_VIEW: ViewOptions = {
instrumentName: METRIC_NAME_GFE_LATENCIES,
aggregation: new ExplicitBucketHistogramAggregation(
HISTOGRAM_BUCKET_BOUNDARIES,
),
});
aggregation: HISTOGRAM_AGGREGATION,
};
export const AFE_LATENCY_VIEW = new View({
export const AFE_LATENCY_VIEW: ViewOptions = {
instrumentName: METRIC_NAME_AFE_LATENCIES,
aggregation: new ExplicitBucketHistogramAggregation(
HISTOGRAM_BUCKET_BOUNDARIES,
),
});
aggregation: HISTOGRAM_AGGREGATION,
};
export const OPERATION_LATENCY_VIEW = new View({
instrumentName: METRIC_NAME_OPERATION_LATENCIES,
aggregation: Aggregation.ExplicitBucketHistogram(HISTOGRAM_BUCKET_BOUNDARIES),
});
export const ATTEMPT_LATENCY_VIEW = new View({
instrumentName: METRIC_NAME_ATTEMPT_LATENCIES,
aggregation: Aggregation.ExplicitBucketHistogram(HISTOGRAM_BUCKET_BOUNDARIES),
});
export const GFE_LATENCY_VIEW = new View({
instrumentName: METRIC_NAME_GFE_LATENCIES,
aggregation: Aggregation.ExplicitBucketHistogram(HISTOGRAM_BUCKET_BOUNDARIES),
});
export const AFE_LATENCY_VIEW = new View({
instrumentName: METRIC_NAME_AFE_LATENCIES,
aggregation: Aggregation.ExplicitBucketHistogram(HISTOGRAM_BUCKET_BOUNDARIES),
});

@alkatrivedi
alkatrivedi force-pushed the node-version-upgrade-22 branch from 3846226 to 290ea16 Compare September 11, 2026 14:41
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.

1 participant