Skip to content

Commit fc22266

Browse files
author
Stephen Belanger
committed
diagnostics_channel: Avoid wrapping with no subscribers
1 parent 4488782 commit fc22266

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/diagnostics_channel.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ class TracingChannel {
178178
}
179179

180180
traceSync(fn, ctx = {}, thisArg, ...args) {
181+
if (!this.hasSubscribers) return ReflectApply(fn, thisArg, args);
181182
const { start, end, error } = this.channels;
182183
start.publish(ctx);
183184
try {
@@ -194,6 +195,7 @@ class TracingChannel {
194195
}
195196

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

@@ -223,6 +225,7 @@ class TracingChannel {
223225
}
224226

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

0 commit comments

Comments
 (0)