Jump to headingTracingChannel.prototype.traceSync<ThisArg = any,Args extends any[] = any[],>(fn: (this: ThisArg,...args: Args,) => any,context?: ContextType,thisArg?: ThisArg,...args: Args,): voidTrace a synchronous function call. This will always produce a start event and end event around the execution and may produce an error event if the given function throws an error.
This will run the given function using channel.runStores(context, ...) on the start channel which ensures all
events should have any bound stores set to match this trace context.
To ensure only correct trace graphs are formed, events will only be published if subscribers are present prior to starting the trace. Subscriptions which are added after the trace begins will not receive future events from that trace, only future traces will be seen.
import diagnostics_channel from 'node:diagnostics_channel';
const channels = diagnostics_channel.tracingChannel('my-channel');
channels.traceSync(() => {
// Do something
}, {
some: 'thing',
});
Type Parameters Jump to heading
Jump to headingThisArg = anyJump to headingArgs extends any[] = any[]Parameters Jump to heading
Jump to headingfn: () => anyFunction to wrap a trace around
Jump to headingcontext: ContextTypeShared object to correlate events through
Jump to headingthisArg: ThisArgThe receiver to be used for the function call
Jump to heading<span>...args</span>: ArgsReturn Type Jump to heading
voidThe return value of the given function