Skip to content

Commit

Permalink
Merge pull request #2817 from ygalbel/tracer-slow
Browse files Browse the repository at this point in the history
made the call to trace to be called only when tracer is enabled
  • Loading branch information
murgatroid99 committed Sep 5, 2024
2 parents c63bdae + 90e472e commit bb4496b
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/grpc-js/src/internal-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
getDefaultAuthority,
mapUriDefaultScheme,
} from './resolver';
import { trace } from './logging';
import { trace, isTracerEnabled } from './logging';
import { SubchannelAddress } from './subchannel-address';
import { mapProxyName } from './http_proxy';
import { GrpcUri, parseUri, uriToString } from './uri-parser';
Expand Down Expand Up @@ -424,15 +424,17 @@ export class InternalChannel {
JSON.stringify(options, undefined, 2)
);
const error = new Error();
trace(
LogVerbosity.DEBUG,
'channel_stacktrace',
'(' +
this.channelzRef.id +
') ' +
'Channel constructed \n' +
error.stack?.substring(error.stack.indexOf('\n') + 1)
);
if (isTracerEnabled('channel_stacktrace')){
trace(
LogVerbosity.DEBUG,
'channel_stacktrace',
'(' +
this.channelzRef.id +
') ' +
'Channel constructed \n' +
error.stack?.substring(error.stack.indexOf('\n') + 1)
);
}
this.lastActivityTimestamp = new Date();
}

Expand Down

0 comments on commit bb4496b

Please sign in to comment.