Skip to content

Commit 97584dc

Browse files
committed
grpc-js: Add channel construction stacktrace traces
1 parent d8e73f3 commit 97584dc

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

doc/environment_variables.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ can be set.
3939
- `subchannel_refcount` - Traces subchannel refcount changes. Includes per-call logs.
4040
- `subchannel_flowctrl` - Traces HTTP/2 flow control. Includes per-call logs.
4141
- `subchannel_internals` - Traces HTTP/2 session state. Includes per-call logs.
42+
- `channel_stacktrace` - Traces channel construction events with stack traces.
4243

4344
The following tracers are added by the `@grpc/grpc-js-xds` library:
4445
- `cds_balancer` - Traces the CDS load balancing policy

packages/grpc-js/src/channel.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ export class ChannelImplementation implements Channel {
335335
new CompressionFilterFactory(this, this.options),
336336
]);
337337
this.trace('Channel constructed with options ' + JSON.stringify(options, undefined, 2));
338+
const error = new Error();
339+
trace(LogVerbosity.DEBUG, 'channel_stacktrace', '(' + this.channelzRef.id + ') ' + 'Channel constructed \n' + error.stack?.substring(error.stack.indexOf('\n')+1));
338340
}
339341

340342
private getChannelzInfo(): ChannelInfo {

0 commit comments

Comments
 (0)