Skip to content
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

feat(debugging): implement x-goog-spanner-request-id propagation per request #2205

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

odeke-em
Copy link
Contributor

Implements propagation of the x-goog-spanner-request-id that'll be propagated for every call. Once an error has been encountered, that error will have .requestId set.

Fixes #2200

@odeke-em odeke-em requested review from a team as code owners December 21, 2024 14:07
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: spanner Issues related to the googleapis/nodejs-spanner API. labels Dec 21, 2024
@odeke-em odeke-em force-pushed the x-goog-spanner-request-id branch 3 times, most recently from 1f5c031 to 85f6d7a Compare December 21, 2024 16:13
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Dec 21, 2024
@odeke-em odeke-em force-pushed the x-goog-spanner-request-id branch 2 times, most recently from 323edc3 to fc4a2de Compare December 22, 2024 12:40
@odeke-em odeke-em force-pushed the x-goog-spanner-request-id branch 2 times, most recently from 210bbc1 to b6e7308 Compare December 24, 2024 19:05
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. and removed size: l Pull request size is large. labels Dec 24, 2024
@odeke-em odeke-em force-pushed the x-goog-spanner-request-id branch 2 times, most recently from c27ba41 to 12efa68 Compare December 24, 2024 19:08
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: xl Pull request size is extra large. labels Dec 24, 2024
@odeke-em odeke-em force-pushed the x-goog-spanner-request-id branch from 12efa68 to e823c42 Compare December 27, 2024 15:34
@odeke-em
Copy link
Contributor Author

@olavloite @surbhigarg92 kindly help me take a look at this PR, it is ready for review. Thank you!

@odeke-em odeke-em force-pushed the x-goog-spanner-request-id branch from 54d1188 to 918f802 Compare January 6, 2025 01:18
odeke-em added a commit to odeke-em/nodejs-spanner that referenced this pull request Jan 7, 2025
This change brings in the bases for x-goog-spanner-request-id
by commit AtomicCounter and the various utilities plus some
unit tests.

Ripped out of PR googleapis#2205
Updates  googleapis#2200
odeke-em added a commit to odeke-em/nodejs-spanner that referenced this pull request Jan 24, 2025
This change brings in the bases for x-goog-spanner-request-id
by commit AtomicCounter and the various utilities plus some
unit tests.

Ripped out of PR googleapis#2205
Updates  googleapis#2200
odeke-em added a commit to odeke-em/nodejs-spanner that referenced this pull request Feb 6, 2025
This change brings in the bases for x-goog-spanner-request-id
by commit AtomicCounter and the various utilities plus some
unit tests.

Ripped out of PR googleapis#2205
Updates  googleapis#2200
odeke-em added a commit to odeke-em/nodejs-spanner that referenced this pull request Feb 8, 2025
This change brings in the bases for x-goog-spanner-request-id
by commit AtomicCounter and the various utilities plus some
unit tests.

Ripped out of PR googleapis#2205
Updates  googleapis#2200
olavloite added a commit that referenced this pull request Feb 9, 2025
* feat(x-goog-spanner-request-id): add bases

This change brings in the bases for x-goog-spanner-request-id
by commit AtomicCounter and the various utilities plus some
unit tests.

Ripped out of PR #2205
Updates  #2200

* Fix lint

* Address review comments

* Address more review feedback

* fix: format process-id as a 32-bit hex number

* chore: fix formatting issue

* fix: left-pad process-id

* fix: no of elements after process-id should be 4

---------

Co-authored-by: Knut Olav Løite <[email protected]>
@odeke-em odeke-em force-pushed the x-goog-spanner-request-id branch from b8630f5 to 253d879 Compare February 9, 2025 22:34
@odeke-em odeke-em requested a review from a team as a code owner February 9, 2025 22:34
…request

Implements propagation of the x-goog-spanner-request-id that'll be
propagated for every call. Once an error has been encountered, that
error will have `.requestId` set.

Fixes googleapis#2200
@odeke-em odeke-em force-pushed the x-goog-spanner-request-id branch from 253d879 to e683e25 Compare February 9, 2025 22:44
@olavloite olavloite added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Feb 10, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Feb 10, 2025
test/spanner.ts Outdated
@@ -170,6 +313,7 @@ describe('Spanner with mock server', () => {
servicePath: 'localhost',
port,
sslCreds: grpc.credentials.createInsecure(),
// interceptors: [xGoogReqIDInterceptor.generateLoggingClientInterceptor()],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove?

test/spanner.ts Outdated
@@ -2690,6 +2877,7 @@ describe('Spanner with mock server', () => {
(e as ServiceError).message,
'No resources available.'
);
// assert.deepStrictEqual((e as RequestIDError).requestID,`1.${randIdForProcess}.1.1.1.1`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this commented?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is because that error isn't sent via RPC but really just thrown when fail: true is set.

test/spanner.ts Outdated Show resolved Hide resolved
test/spanner.ts Outdated
@@ -2825,6 +3014,7 @@ describe('Spanner with mock server', () => {
(err as ServiceError).code,
Status.PERMISSION_DENIED
);
// assert.deepStrictEqual((err as RequestIDError).requestID,`1.${randIdForProcess}.1.1.1.1`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove?

@@ -88,6 +88,8 @@ function newAtomicCounter(n?: number): AtomicCounter {
return new AtomicCounter(n);
}

const X_GOOG_REQ_ID_REGEX = /(\d+\.){5}\d+/;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used anywhere? (If it is, then that is probably an indication of a small bug, as it assumes that the process id consists of only digits)

Comment on lines +338 to +340
// TODO: Negotiate with the Google team to plumb gRPC
// settings such as interceptors to the gRPC client.
// 'grpc.interceptors': interceptors,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the status of this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No action at all sadly, I reported to the maintainers of this library but out of scope currently and not a priority for them.

this.commonHeaders_,
this,
nextNthRequest(database),
1
Copy link
Contributor

Choose a reason for hiding this comment

The 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 tests for retried RPCs.

@odeke-em odeke-em force-pushed the x-goog-spanner-request-id branch from 88c617d to ebab047 Compare February 11, 2025 16:20
};
withReqId[X_GOOG_SPANNER_REQUEST_ID_HEADER] = craftRequestId(
this._clientId || 1,
1, // TODO: Properly infer the channelId
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@olavloite I filed a TODO for retrieving the channelId which I believe can be done much later in a phased series of PRs instead of at once.

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 googleapis/nodejs-spanner API. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement propagation of x-goog-spanner-request-id gRPC header on every call
3 participants