-
Notifications
You must be signed in to change notification settings - Fork 105
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
base: main
Are you sure you want to change the base?
Conversation
1f5c031
to
85f6d7a
Compare
323edc3
to
fc4a2de
Compare
210bbc1
to
b6e7308
Compare
c27ba41
to
12efa68
Compare
12efa68
to
e823c42
Compare
@olavloite @surbhigarg92 kindly help me take a look at this PR, it is ready for review. Thank you! |
54d1188
to
918f802
Compare
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
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
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
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
* 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]>
b8630f5
to
253d879
Compare
…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
253d879
to
e683e25
Compare
test/spanner.ts
Outdated
@@ -170,6 +313,7 @@ describe('Spanner with mock server', () => { | |||
servicePath: 'localhost', | |||
port, | |||
sslCreds: grpc.credentials.createInsecure(), | |||
// interceptors: [xGoogReqIDInterceptor.generateLoggingClientInterceptor()], |
There was a problem hiding this comment.
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`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this commented?
There was a problem hiding this comment.
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
@@ -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`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove?
src/request_id_header.ts
Outdated
@@ -88,6 +88,8 @@ function newAtomicCounter(n?: number): AtomicCounter { | |||
return new AtomicCounter(n); | |||
} | |||
|
|||
const X_GOOG_REQ_ID_REGEX = /(\d+\.){5}\d+/; |
There was a problem hiding this comment.
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)
// TODO: Negotiate with the Google team to plumb gRPC | ||
// settings such as interceptors to the gRPC client. | ||
// 'grpc.interceptors': interceptors, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
88c617d
to
ebab047
Compare
}; | ||
withReqId[X_GOOG_SPANNER_REQUEST_ID_HEADER] = craftRequestId( | ||
this._clientId || 1, | ||
1, // TODO: Properly infer the channelId |
There was a problem hiding this comment.
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.
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