Skip to content

Commit d8e73f3

Browse files
authored
Merge pull request #2059 from murgatroid99/grpc-js_trace_more_ids
grpc-js: Consistently log subchannel and call IDs in traces
2 parents fc686e3 + 5a601b0 commit d8e73f3

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

packages/grpc-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@grpc/grpc-js",
3-
"version": "1.5.7",
3+
"version": "1.5.8",
44
"description": "gRPC Library for Node - pure JS implementation",
55
"homepage": "https://grpc.io/",
66
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",

packages/grpc-js/src/call-stream.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,10 @@ export class Http2CallStream implements Call {
795795
this.filterStack.push(extraFilters);
796796
}
797797

798+
getCallNumber() {
799+
return this.callNumber;
800+
}
801+
798802
startRead() {
799803
/* If the stream has ended with an error, we should not emit any more
800804
* messages and we should communicate that the stream has ended */

packages/grpc-js/src/channel.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -404,11 +404,16 @@ export class ChannelImplementation implements Channel {
404404
metadata: callMetadata,
405405
extraPickInfo: callConfig.pickInformation,
406406
});
407+
const subchannelString = pickResult.subchannel ?
408+
'(' + pickResult.subchannel.getChannelzRef().id + ') ' + pickResult.subchannel.getAddress() :
409+
'' + pickResult.subchannel;
407410
this.trace(
408-
'Pick result: ' +
411+
'Pick result for call [' +
412+
callStream.getCallNumber() +
413+
']: ' +
409414
PickResultType[pickResult.pickResultType] +
410415
' subchannel: ' +
411-
pickResult.subchannel?.getAddress() +
416+
subchannelString +
412417
' status: ' +
413418
pickResult.status?.code +
414419
' ' +
@@ -433,7 +438,7 @@ export class ChannelImplementation implements Channel {
433438
log(
434439
LogVerbosity.ERROR,
435440
'Error: COMPLETE pick result subchannel ' +
436-
pickResult.subchannel!.getAddress() +
441+
subchannelString +
437442
' has state ' +
438443
ConnectivityState[pickResult.subchannel!.getConnectivityState()]
439444
);
@@ -480,7 +485,7 @@ export class ChannelImplementation implements Channel {
480485
* tryPick */
481486
this.trace(
482487
'Failed to start call on picked subchannel ' +
483-
pickResult.subchannel!.getAddress() +
488+
subchannelString +
484489
' with error ' +
485490
(error as Error).message +
486491
'. Retrying pick',
@@ -490,7 +495,7 @@ export class ChannelImplementation implements Channel {
490495
} else {
491496
this.trace(
492497
'Failed to start call on picked subchanel ' +
493-
pickResult.subchannel!.getAddress() +
498+
subchannelString +
494499
' with error ' +
495500
(error as Error).message +
496501
'. Ending call',
@@ -509,7 +514,7 @@ export class ChannelImplementation implements Channel {
509514
* block above */
510515
this.trace(
511516
'Picked subchannel ' +
512-
pickResult.subchannel!.getAddress() +
517+
subchannelString +
513518
' has state ' +
514519
ConnectivityState[subchannelState] +
515520
' after metadata filters. Retrying pick',

packages/grpc-js/src/subchannel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ export class Subchannel {
857857
logging.trace(
858858
LogVerbosity.DEBUG,
859859
'call_stream',
860-
'Starting stream on subchannel ' +
860+
'Starting stream [' + callStream.getCallNumber() + '] on subchannel ' +
861861
'(' + this.channelzRef.id + ') ' +
862862
this.subchannelAddressString +
863863
' with headers\n' +

0 commit comments

Comments
 (0)