perf(spanner): avoid cloning metadata map in metrics interceptor - #9307
Merged
Merged
Conversation
MetricInterceptor previously called metadata.getMap() to read the
server-timing response header. getMap() constructs a fresh object
and copies every response header, creating unnecessary allocations
and iteration overhead on every RPC attempt.
This change replaces getMap() with a direct metadata.get('server-timing')
lookup, reading the header value without cloning the entire metadata
dictionary.
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the MetricInterceptor to retrieve the server-timing header using metadata.get('server-timing') instead of metadata.getMap(), extracting the first entry if available. It also adds a corresponding unit test to verify this behavior and removes BOM characters from the copyright headers. There are no review comments, so no feedback is provided.
sakthivelmanii
approved these changes
Sep 14, 2026
danieljbruce
pushed a commit
that referenced
this pull request
Sep 14, 2026
🤖 I have created a release *beep* *boop* --- ## [8.13.0](spanner-v8.12.0...spanner-v8.13.0) (2026-09-14) ### Features * PNPM workspace ([#8973](#8973)) ([1ea27c9](1ea27c9)) ### Bug Fixes * **spanner:** Do not execute queued queries on ended transactions ([#9305](#9305)) ([f74f198](f74f198)) ### Performance Improvements * **spanner:** Avoid cloning metadata map in metrics interceptor ([#9307](#9307)) ([6eec761](6eec761)) * **spanner:** Avoid redundant clock reads in isGlobalTracingEnabled ([#9311](#9311)) ([c42f144](c42f144)) * **spanner:** Bypass stream pipeline for single-chunk query results ([#9279](#9279)) ([e46a407](e46a407)) --- 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>
thiyaguk09
pushed a commit
to thiyaguk09/google-cloud-node-fork
that referenced
this pull request
Sep 15, 2026
🤖 I have created a release *beep* *boop* --- ## [8.13.0](googleapis/google-cloud-node@spanner-v8.12.0...spanner-v8.13.0) (2026-09-14) ### Features * PNPM workspace ([googleapis#8973](googleapis#8973)) ([1ea27c9](googleapis@1ea27c9)) ### Bug Fixes * **spanner:** Do not execute queued queries on ended transactions ([googleapis#9305](googleapis#9305)) ([f74f198](googleapis@f74f198)) ### Performance Improvements * **spanner:** Avoid cloning metadata map in metrics interceptor ([googleapis#9307](googleapis#9307)) ([6eec761](googleapis@6eec761)) * **spanner:** Avoid redundant clock reads in isGlobalTracingEnabled ([googleapis#9311](googleapis#9311)) ([c42f144](googleapis@c42f144)) * **spanner:** Bypass stream pipeline for single-chunk query results ([googleapis#9279](googleapis#9279)) ([e46a407](googleapis@e46a407)) --- 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 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.
MetricInterceptor previously called metadata.getMap() to read the server-timing response header. getMap() constructs a fresh object and copies every response header, creating unnecessary allocations and iteration overhead on every RPC attempt.
This change replaces getMap() with a direct metadata.get('server-timing') lookup, reading the header value without cloning the entire metadata dictionary.