Skip to main content
TracingChannel.prototype.tracePromise - node__diagnostics_channel.d.ts - Node documentation
method TracingChannel.prototype.tracePromise
Unstable

Usage in Deno

```typescript import { TracingChannel } from "node:node__diagnostics_channel.d.ts"; ```
TracingChannel.prototype.tracePromise<
ThisArg = any,
Args extends any[] = any[],
>
(
fn: (
this: ThisArg,
...args: Args,
) => Promise<any>
,
context?: ContextType,
thisArg?: ThisArg,
...args: Args,
): void
Trace a promise-returning function call. This will always produce a `start event` and `end event` around the synchronous portion of the function execution, and will produce an `asyncStart event` and `asyncEnd event` when a promise continuation is reached. It may also produce an `error event` if the given function throws an error or the returned promise rejects. 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. ```js import diagnostics_channel from 'node:diagnostics_channel'; const channels = diagnostics_channel.tracingChannel('my-channel'); channels.tracePromise(async () => { // Do something }, { some: 'thing', }); ```

Type Parameters

ThisArg = any
Args extends any[] = any[]

Parameters

fn: (
this: ThisArg,
...args: Args,
) => Promise<any>
Promise-returning function to wrap a trace around
optional
context: ContextType
Shared object to correlate trace events through
optional
thisArg: ThisArg
The receiver to be used for the function call
...args: Args

Return Type

void
Chained from promise returned by the given function