Skip to content

fix(spanner): set gauge metric start time to match end time#14289

Merged
sakthivelmanii merged 1 commit intomainfrom
fix/grpc-metrics-gauge-aggregation
Apr 1, 2026
Merged

fix(spanner): set gauge metric start time to match end time#14289
sakthivelmanii merged 1 commit intomainfrom
fix/grpc-metrics-gauge-aggregation

Conversation

@sakthivelmanii
Copy link
Copy Markdown
Contributor

@sakthivelmanii sakthivelmanii commented Mar 29, 2026

This commit fixes an InvalidArgument error ("One or more points were written
more frequently than the maximum sampling period") when exporting gauge metrics
like open_connections to Cloud Monitoring.

Previously, the time interval for these gauge metrics started from the moment
the application booted up. This created long, continuously overlapping time
intervals. Cloud Monitoring strictly rejected these because it requires gauges
to be exact, point-in-time measurements, not long durations.

By simply setting the start time equal to the end time (start = end), we
correctly format the data as instantaneous point-in-time snapshots. This
satisfies Cloud Monitoring's requirements and allows the metrics to export
successfully on every cycle.

@sakthivelmanii sakthivelmanii requested review from a team as code owners March 29, 2026 19:19
@sakthivelmanii sakthivelmanii changed the title fix: use AggregationDefault for spanner grpc metrics fix(spanner): use AggregationDefault for spanner grpc metrics Mar 29, 2026
@sakthivelmanii sakthivelmanii force-pushed the fix/grpc-metrics-gauge-aggregation branch from 51dbbb8 to ed415d3 Compare March 29, 2026 19:20
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

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 updates the Spanner metrics configuration to use default aggregation and introduces a new test case, TestBuiltinMetrics_GaugeAggregation, to verify gauge aggregation and attribute filtering. The review feedback suggests improving test stability by replacing a hardcoded sleep with a polling mechanism and removing a redundant manual exporter stop call while ensuring the meter provider shutdown uses a non-cancelable context.

Comment thread spanner/metric_monitoring_exporter_test.go Outdated
Comment thread spanner/metric_monitoring_exporter_test.go Outdated
@sakthivelmanii sakthivelmanii force-pushed the fix/grpc-metrics-gauge-aggregation branch from ed415d3 to 2c99011 Compare March 29, 2026 19:30
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label Mar 30, 2026
This commit fixes an InvalidArgument error ("One or more points were written
more frequently than the maximum sampling period") when exporting gauge metrics
like `open_connections` to Cloud Monitoring.

Previously, the time interval for these gauge metrics started from the moment
the application booted up. This created long, continuously overlapping time
intervals. Cloud Monitoring strictly rejected these because it requires gauges
to be exact, point-in-time measurements, not long durations.

By simply setting the start time equal to the end time (`start = end`), we
correctly format the data as instantaneous point-in-time snapshots. This
satisfies Cloud Monitoring's requirements and allows the metrics to export
successfully on every cycle.
@sakthivelmanii sakthivelmanii force-pushed the fix/grpc-metrics-gauge-aggregation branch from 82b5d26 to 9db9693 Compare April 1, 2026 11:35
@sakthivelmanii sakthivelmanii changed the title fix(spanner): use AggregationDefault for spanner grpc metrics fix(spanner): set gauge metric start time to match end time Apr 1, 2026
@sakthivelmanii
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

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 modifies the toNonemptyTimeIntervalpb function in spanner/metrics_monitoring_exporter.go to set the start time equal to the end time for gauge metrics, ensuring compliance with the Cloud Monitoring API requirements for time intervals. I have no feedback to provide as no review comments were submitted.

@sakthivelmanii sakthivelmanii merged commit e0760b5 into main Apr 1, 2026
10 checks passed
@sakthivelmanii sakthivelmanii deleted the fix/grpc-metrics-gauge-aggregation branch April 1, 2026 19:11
rahul2393 added a commit that referenced this pull request Apr 14, 2026
PR created by the Librarian CLI to initialize a release. Merging this PR
will auto trigger a release.

Librarian Version: v0.10.1
Language Image:
us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/librarian-go@sha256:b04b076f5eedbb5546bd6fc1404969dd3698c8b19c0f34ae815a84ae735a606a
<details><summary>spanner: v1.90.0</summary>

##
[v1.90.0](spanner/v1.89.0...spanner/v1.90.0)
(2026-04-14)

### Features

* feat(spanner): add EnableDirectAccess field to ClientConfig (#14287)
([6adf5b7](6adf5b7))
* feat(spanner): Switch to using builtin open telemetry for EEF
(#14193)([751febd](751febd))
* feat(spanner): complete location-aware routing resilience and
observability (#14418 )
([77aa4df](77aa4df))

###  Bug Fixes


* fix(spanner): set gauge metric start time to match end time (#14289)
([e0760b5](e0760b5))
* fix(spanner): update DirectPath detection logic to use ALTS
credentials(#14288)([3cd5716](3cd5716))

</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the Spanner API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants