-
Notifications
You must be signed in to change notification settings - Fork 110
feat(debugging): implement x-goog-spanner-request-id propagation per request #2205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
olavloite
merged 8 commits into
googleapis:main
from
odeke-em:x-goog-spanner-request-id
Mar 23, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d444161
feat(debugging): implement x-goog-spanner-request-id propagation per …
odeke-em c301dc3
All: update tests
odeke-em 3b2fae5
Address review feedback
odeke-em ed0a691
Remove a redundant prefix check for values to skip
odeke-em 54bc377
Put TODO in correct place for retries from GAX
odeke-em 345f35f
test: add test to verify that request-id is received
olavloite ff9678b
Revert protos/* spurious updates
odeke-em 2565965
Correctly check for ExecuteStreamingSql headers asynchronously in cal…
odeke-em File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ import { | |
import {grpc, CallOptions} from 'google-gax'; | ||
import IRequestOptions = google.spanner.v1.IRequestOptions; | ||
import {Spanner} from '.'; | ||
|
||
import {injectRequestIDIntoHeaders, nextNthRequest} from './request_id_header'; | ||
export type GetSessionResponse = [Session, r.Response]; | ||
|
||
/** | ||
|
@@ -317,13 +317,19 @@ export class Session extends common.GrpcServiceObject { | |
const reqOpts = { | ||
name: this.formattedName_, | ||
}; | ||
const database = this.parent as Database; | ||
return this.request( | ||
{ | ||
client: 'SpannerClient', | ||
method: 'deleteSession', | ||
reqOpts, | ||
gaxOpts, | ||
headers: this.commonHeaders_, | ||
headers: injectRequestIDIntoHeaders( | ||
this.commonHeaders_, | ||
this, | ||
nextNthRequest(database), | ||
1 | ||
), | ||
}, | ||
callback! | ||
); | ||
|
@@ -389,13 +395,19 @@ export class Session extends common.GrpcServiceObject { | |
if (this._getSpanner().routeToLeaderEnabled) { | ||
addLeaderAwareRoutingHeader(headers); | ||
} | ||
const database = this.parent as Database; | ||
return this.request( | ||
{ | ||
client: 'SpannerClient', | ||
method: 'getSession', | ||
reqOpts, | ||
gaxOpts, | ||
headers: headers, | ||
headers: injectRequestIDIntoHeaders( | ||
headers, | ||
this.session, | ||
nextNthRequest(database), | ||
1 | ||
), | ||
}, | ||
(err, resp) => { | ||
if (resp) { | ||
|
@@ -441,17 +453,25 @@ export class Session extends common.GrpcServiceObject { | |
session: this.formattedName_, | ||
sql: 'SELECT 1', | ||
}; | ||
|
||
const database = this.parent as Database; | ||
return this.request( | ||
{ | ||
client: 'SpannerClient', | ||
method: 'executeSql', | ||
reqOpts, | ||
gaxOpts, | ||
headers: this.commonHeaders_, | ||
headers: injectRequestIDIntoHeaders( | ||
this.commonHeaders_, | ||
this, | ||
nextNthRequest(database), | ||
1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think attempt is ever set to any value higher than 1. There are also no tests for retried RPCs. |
||
), | ||
}, | ||
callback! | ||
); | ||
} | ||
|
||
/** | ||
* Create a PartitionedDml transaction. | ||
* | ||
|
@@ -534,6 +554,11 @@ export class Session extends common.GrpcServiceObject { | |
private _getSpanner(): Spanner { | ||
return this.parent.parent.parent as Spanner; | ||
} | ||
|
||
private channelId(): number { | ||
// The Node.js client does not use a gRPC channel pool, so this always returns 1. | ||
return 1; | ||
} | ||
} | ||
|
||
/*! Developer Documentation | ||
|
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.