Skip to content

Commit bb4496b

Browse files
authoredSep 5, 2024
Merge pull request #2817 from ygalbel/tracer-slow
made the call to trace to be called only when tracer is enabled
2 parents c63bdae + 90e472e commit bb4496b

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed
 

‎packages/grpc-js/src/internal-channel.ts

+12-10
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
getDefaultAuthority,
3232
mapUriDefaultScheme,
3333
} from './resolver';
34-
import { trace } from './logging';
34+
import { trace, isTracerEnabled } from './logging';
3535
import { SubchannelAddress } from './subchannel-address';
3636
import { mapProxyName } from './http_proxy';
3737
import { GrpcUri, parseUri, uriToString } from './uri-parser';
@@ -424,15 +424,17 @@ export class InternalChannel {
424424
JSON.stringify(options, undefined, 2)
425425
);
426426
const error = new Error();
427-
trace(
428-
LogVerbosity.DEBUG,
429-
'channel_stacktrace',
430-
'(' +
431-
this.channelzRef.id +
432-
') ' +
433-
'Channel constructed \n' +
434-
error.stack?.substring(error.stack.indexOf('\n') + 1)
435-
);
427+
if (isTracerEnabled('channel_stacktrace')){
428+
trace(
429+
LogVerbosity.DEBUG,
430+
'channel_stacktrace',
431+
'(' +
432+
this.channelzRef.id +
433+
') ' +
434+
'Channel constructed \n' +
435+
error.stack?.substring(error.stack.indexOf('\n') + 1)
436+
);
437+
}
436438
this.lastActivityTimestamp = new Date();
437439
}
438440

0 commit comments

Comments
 (0)
Please sign in to comment.