Skip to content

Commit

Permalink
diagnostics_channel: Avoid wrapping with no subscribers
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Belanger committed Nov 9, 2022
1 parent 4488782 commit fc22266
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/diagnostics_channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class TracingChannel {
}

traceSync(fn, ctx = {}, thisArg, ...args) {
if (!this.hasSubscribers) return ReflectApply(fn, thisArg, args);
const { start, end, error } = this.channels;
start.publish(ctx);
try {
Expand All @@ -194,6 +195,7 @@ class TracingChannel {
}

tracePromise(fn, ctx = {}, thisArg, ...args) {
if (!this.hasSubscribers) return ReflectApply(fn, thisArg, args);
const { asyncEnd, start, end, error } = this.channels;
start.publish(ctx);

Expand Down Expand Up @@ -223,6 +225,7 @@ class TracingChannel {
}

traceCallback(fn, position = 0, ctx = {}, thisArg, ...args) {
if (!this.hasSubscribers) return ReflectApply(fn, thisArg, args);
const { start, end, asyncEnd, error } = this.channels;
start.publish(ctx);

Expand Down

0 comments on commit fc22266

Please sign in to comment.