feat(Spanner): migrate the metrics exporter from a custom one to a native OTLP one. - #9505
Open
Hectorhammett wants to merge 3 commits into
Open
feat(Spanner): migrate the metrics exporter from a custom one to a native OTLP one.#9505Hectorhammett wants to merge 3 commits into
Hectorhammett wants to merge 3 commits into
Conversation
Hectorhammett
force-pushed
the
otel-migration
branch
from
August 19, 2026 02:13
51886e8 to
b117418
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In the past when we introduced client metrics, we implemented a custom exporter (
MetricServiceClient) to translate metrics into Google Cloud MonitoringTimeSeriesobjects because GCP did not yet support the native OTLP protocol.Google Cloud now natively supports OTLP metric ingestion at
https://telemetry.googleapis.com/v1/metrics. This PR updates the Spanner PHP SDK built-in metrics exporter to use standard OTLP HTTP export and adds support for configurable metrics credentials.Key Changes
MetricServiceClientGCM translation inMetricsExporterwith standard OTLP HTTP exporter (OpenTelemetry\Contrib\Otlp\MetricExporter) targetinghttps://telemetry.googleapis.com/v1/metrics.$options['metricsCredentials']inSpannerClient.https://www.googleapis.com/auth/monitoring.writeandhttps://www.googleapis.com/auth/cloud-platformusingCredentialsWrapperto prevent OAuth scope mismatch errors.Authorization: Bearer <token>andx-goog-user-projectheaders to outgoing OTLP HTTP requests via Guzzle middleware.