Skip to content

Commit

Permalink
grpc-js: Consistently log subchannel and call IDs in traces
Browse files Browse the repository at this point in the history
  • Loading branch information
murgatroid99 committed Mar 14, 2022
1 parent fc686e3 commit 5a601b0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/grpc-js/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 4 additions & 0 deletions packages/grpc-js/src/call-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
17 changes: 11 additions & 6 deletions packages/grpc-js/src/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 +
' ' +
Expand All @@ -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()]
);
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion packages/grpc-js/src/subchannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' +
Expand Down

0 comments on commit 5a601b0

Please sign in to comment.