Merge pull request #2059 from murgatroid99/grpc-js_trace_more_ids

grpc-js: Consistently log subchannel and call IDs in traces
This commit is contained in:
Michael Lumish 2022-03-14 12:48:03 -07:00 committed by GitHub
commit d8e73f3b22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 8 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@grpc/grpc-js",
"version": "1.5.7",
"version": "1.5.8",
"description": "gRPC Library for Node - pure JS implementation",
"homepage": "https://grpc.io/",
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",

View File

@ -795,6 +795,10 @@ export class Http2CallStream implements Call {
this.filterStack.push(extraFilters);
}
getCallNumber() {
return this.callNumber;
}
startRead() {
/* If the stream has ended with an error, we should not emit any more
* messages and we should communicate that the stream has ended */

View File

@ -404,11 +404,16 @@ export class ChannelImplementation implements Channel {
metadata: callMetadata,
extraPickInfo: callConfig.pickInformation,
});
const subchannelString = pickResult.subchannel ?
'(' + pickResult.subchannel.getChannelzRef().id + ') ' + pickResult.subchannel.getAddress() :
'' + pickResult.subchannel;
this.trace(
'Pick result: ' +
'Pick result for call [' +
callStream.getCallNumber() +
']: ' +
PickResultType[pickResult.pickResultType] +
' subchannel: ' +
pickResult.subchannel?.getAddress() +
subchannelString +
' status: ' +
pickResult.status?.code +
' ' +
@ -433,7 +438,7 @@ export class ChannelImplementation implements Channel {
log(
LogVerbosity.ERROR,
'Error: COMPLETE pick result subchannel ' +
pickResult.subchannel!.getAddress() +
subchannelString +
' has state ' +
ConnectivityState[pickResult.subchannel!.getConnectivityState()]
);
@ -480,7 +485,7 @@ export class ChannelImplementation implements Channel {
* tryPick */
this.trace(
'Failed to start call on picked subchannel ' +
pickResult.subchannel!.getAddress() +
subchannelString +
' with error ' +
(error as Error).message +
'. Retrying pick',
@ -490,7 +495,7 @@ export class ChannelImplementation implements Channel {
} else {
this.trace(
'Failed to start call on picked subchanel ' +
pickResult.subchannel!.getAddress() +
subchannelString +
' with error ' +
(error as Error).message +
'. Ending call',
@ -509,7 +514,7 @@ export class ChannelImplementation implements Channel {
* block above */
this.trace(
'Picked subchannel ' +
pickResult.subchannel!.getAddress() +
subchannelString +
' has state ' +
ConnectivityState[subchannelState] +
' after metadata filters. Retrying pick',

View File

@ -857,7 +857,7 @@ export class Subchannel {
logging.trace(
LogVerbosity.DEBUG,
'call_stream',
'Starting stream on subchannel ' +
'Starting stream [' + callStream.getCallNumber() + '] on subchannel ' +
'(' + this.channelzRef.id + ') ' +
this.subchannelAddressString +
' with headers\n' +