Diagnostics Channel#
History
| Version | Changes |
|---|---|
| v19.2.0, v18.13.0 | diagnostics_channel is now Stable. |
| v15.1.0, v14.17.0 | Added in: v15.1.0, v14.17.0 |
Source Code:lib/diagnostics_channel.js
Thenode:diagnostics_channel module provides an API to create named channelsto report arbitrary message data for diagnostics purposes.
It can be accessed using:
import diagnostics_channelfrom'node:diagnostics_channel';const diagnostics_channel =require('node:diagnostics_channel');
It is intended that a module writer wanting to report diagnostics messageswill create one or many top-level channels to report messages through.Channels may also be acquired at runtime but it is not encourageddue to the additional overhead of doing so. Channels may be exported forconvenience, but as long as the name is known it can be acquired anywhere.
If you intend for your module to produce diagnostics data for others toconsume it is recommended that you include documentation of what namedchannels are used along with the shape of the message data. Channel namesshould generally include the module name to avoid collisions with data fromother modules.
Public API#
Overview#
Following is a simple overview of the public API.
import diagnostics_channelfrom'node:diagnostics_channel';// Get a reusable channel objectconst channel = diagnostics_channel.channel('my-channel');functiononMessage(message, name) {// Received data}// Subscribe to the channeldiagnostics_channel.subscribe('my-channel', onMessage);// Check if the channel has an active subscriberif (channel.hasSubscribers) {// Publish data to the channel channel.publish({some:'data', });}// Unsubscribe from the channeldiagnostics_channel.unsubscribe('my-channel', onMessage);const diagnostics_channel =require('node:diagnostics_channel');// Get a reusable channel objectconst channel = diagnostics_channel.channel('my-channel');functiononMessage(message, name) {// Received data}// Subscribe to the channeldiagnostics_channel.subscribe('my-channel', onMessage);// Check if the channel has an active subscriberif (channel.hasSubscribers) {// Publish data to the channel channel.publish({some:'data', });}// Unsubscribe from the channeldiagnostics_channel.unsubscribe('my-channel', onMessage);
diagnostics_channel.hasSubscribers(name)#
Check if there are active subscribers to the named channel. This is helpful ifthe message you want to send might be expensive to prepare.
This API is optional but helpful when trying to publish messages from veryperformance-sensitive code.
import diagnostics_channelfrom'node:diagnostics_channel';if (diagnostics_channel.hasSubscribers('my-channel')) {// There are subscribers, prepare and publish message}const diagnostics_channel =require('node:diagnostics_channel');if (diagnostics_channel.hasSubscribers('my-channel')) {// There are subscribers, prepare and publish message}
diagnostics_channel.channel(name)#
This is the primary entry-point for anyone wanting to publish to a namedchannel. It produces a channel object which is optimized to reduce overhead atpublish time as much as possible.
import diagnostics_channelfrom'node:diagnostics_channel';const channel = diagnostics_channel.channel('my-channel');const diagnostics_channel =require('node:diagnostics_channel');const channel = diagnostics_channel.channel('my-channel');
diagnostics_channel.subscribe(name, onMessage)#
name<string> |<symbol> The channel nameonMessage<Function> The handler to receive channel messages
Register a message handler to subscribe to this channel. This message handlerwill be run synchronously whenever a message is published to the channel. Anyerrors thrown in the message handler will trigger an'uncaughtException'.
import diagnostics_channelfrom'node:diagnostics_channel';diagnostics_channel.subscribe('my-channel',(message, name) => {// Received data});const diagnostics_channel =require('node:diagnostics_channel');diagnostics_channel.subscribe('my-channel',(message, name) => {// Received data});
diagnostics_channel.unsubscribe(name, onMessage)#
name<string> |<symbol> The channel nameonMessage<Function> The previous subscribed handler to remove- Returns:<boolean>
trueif the handler was found,falseotherwise.
Remove a message handler previously registered to this channel withdiagnostics_channel.subscribe(name, onMessage).
import diagnostics_channelfrom'node:diagnostics_channel';functiononMessage(message, name) {// Received data}diagnostics_channel.subscribe('my-channel', onMessage);diagnostics_channel.unsubscribe('my-channel', onMessage);const diagnostics_channel =require('node:diagnostics_channel');functiononMessage(message, name) {// Received data}diagnostics_channel.subscribe('my-channel', onMessage);diagnostics_channel.unsubscribe('my-channel', onMessage);
diagnostics_channel.tracingChannel(nameOrChannels)#
nameOrChannels<string> |<TracingChannel> Channel name orobject containing all theTracingChannel Channels- Returns:<TracingChannel> Collection of channels to trace with
Creates aTracingChannel wrapper for the givenTracingChannel Channels. If a name is given, the corresponding tracingchannels will be created in the form oftracing:${name}:${eventType} whereeventType corresponds to the types ofTracingChannel Channels.
import diagnostics_channelfrom'node:diagnostics_channel';const channelsByName = diagnostics_channel.tracingChannel('my-channel');// or...const channelsByCollection = diagnostics_channel.tracingChannel({start: diagnostics_channel.channel('tracing:my-channel:start'),end: diagnostics_channel.channel('tracing:my-channel:end'),asyncStart: diagnostics_channel.channel('tracing:my-channel:asyncStart'),asyncEnd: diagnostics_channel.channel('tracing:my-channel:asyncEnd'),error: diagnostics_channel.channel('tracing:my-channel:error'),});const diagnostics_channel =require('node:diagnostics_channel');const channelsByName = diagnostics_channel.tracingChannel('my-channel');// or...const channelsByCollection = diagnostics_channel.tracingChannel({start: diagnostics_channel.channel('tracing:my-channel:start'),end: diagnostics_channel.channel('tracing:my-channel:end'),asyncStart: diagnostics_channel.channel('tracing:my-channel:asyncStart'),asyncEnd: diagnostics_channel.channel('tracing:my-channel:asyncEnd'),error: diagnostics_channel.channel('tracing:my-channel:error'),});
Class:Channel#
The classChannel represents an individual named channel within the datapipeline. It is used to track subscribers and to publish messages when thereare subscribers present. It exists as a separate object to avoid channellookups at publish time, enabling very fast publish speeds and allowingfor heavy use while incurring very minimal cost. Channels are created withdiagnostics_channel.channel(name), constructing a channel directlywithnew Channel(name) is not supported.
channel.hasSubscribers#
- Returns:<boolean> If there are active subscribers
Check if there are active subscribers to this channel. This is helpful ifthe message you want to send might be expensive to prepare.
This API is optional but helpful when trying to publish messages from veryperformance-sensitive code.
import diagnostics_channelfrom'node:diagnostics_channel';const channel = diagnostics_channel.channel('my-channel');if (channel.hasSubscribers) {// There are subscribers, prepare and publish message}const diagnostics_channel =require('node:diagnostics_channel');const channel = diagnostics_channel.channel('my-channel');if (channel.hasSubscribers) {// There are subscribers, prepare and publish message}
channel.publish(message)#
message<any> The message to send to the channel subscribers
Publish a message to any subscribers to the channel. This will triggermessage handlers synchronously so they will execute within the same context.
import diagnostics_channelfrom'node:diagnostics_channel';const channel = diagnostics_channel.channel('my-channel');channel.publish({some:'message',});const diagnostics_channel =require('node:diagnostics_channel');const channel = diagnostics_channel.channel('my-channel');channel.publish({some:'message',});
channel.subscribe(onMessage)#
History
| Version | Changes |
|---|---|
| v24.8.0, v22.20.0 | Deprecation revoked. |
| v18.7.0, v16.17.0 | Documentation-only deprecation. |
| v15.1.0, v14.17.0 | Added in: v15.1.0, v14.17.0 |
onMessage<Function> The handler to receive channel messages
Register a message handler to subscribe to this channel. This message handlerwill be run synchronously whenever a message is published to the channel. Anyerrors thrown in the message handler will trigger an'uncaughtException'.
import diagnostics_channelfrom'node:diagnostics_channel';const channel = diagnostics_channel.channel('my-channel');channel.subscribe((message, name) => {// Received data});const diagnostics_channel =require('node:diagnostics_channel');const channel = diagnostics_channel.channel('my-channel');channel.subscribe((message, name) => {// Received data});
channel.unsubscribe(onMessage)#
History
| Version | Changes |
|---|---|
| v24.8.0, v22.20.0 | Deprecation revoked. |
| v18.7.0, v16.17.0 | Documentation-only deprecation. |
| v17.1.0, v16.14.0, v14.19.0 | Added return value. Added to channels without subscribers. |
| v15.1.0, v14.17.0 | Added in: v15.1.0, v14.17.0 |
onMessage<Function> The previous subscribed handler to remove- Returns:<boolean>
trueif the handler was found,falseotherwise.
Remove a message handler previously registered to this channel withchannel.subscribe(onMessage).
import diagnostics_channelfrom'node:diagnostics_channel';const channel = diagnostics_channel.channel('my-channel');functiononMessage(message, name) {// Received data}channel.subscribe(onMessage);channel.unsubscribe(onMessage);const diagnostics_channel =require('node:diagnostics_channel');const channel = diagnostics_channel.channel('my-channel');functiononMessage(message, name) {// Received data}channel.subscribe(onMessage);channel.unsubscribe(onMessage);
channel.bindStore(store[, transform])#
store<AsyncLocalStorage> The store to which to bind the context datatransform<Function> Transform context data before setting the store context
Whenchannel.runStores(context, ...) is called, the given context datawill be applied to any store bound to the channel. If the store has already beenbound the previoustransform function will be replaced with the new one.Thetransform function may be omitted to set the given context data as thecontext directly.
import diagnostics_channelfrom'node:diagnostics_channel';import {AsyncLocalStorage }from'node:async_hooks';const store =newAsyncLocalStorage();const channel = diagnostics_channel.channel('my-channel');channel.bindStore(store,(data) => {return { data };});const diagnostics_channel =require('node:diagnostics_channel');const {AsyncLocalStorage } =require('node:async_hooks');const store =newAsyncLocalStorage();const channel = diagnostics_channel.channel('my-channel');channel.bindStore(store,(data) => {return { data };});
channel.unbindStore(store)#
store<AsyncLocalStorage> The store to unbind from the channel.- Returns:<boolean>
trueif the store was found,falseotherwise.
Remove a message handler previously registered to this channel withchannel.bindStore(store).
import diagnostics_channelfrom'node:diagnostics_channel';import {AsyncLocalStorage }from'node:async_hooks';const store =newAsyncLocalStorage();const channel = diagnostics_channel.channel('my-channel');channel.bindStore(store);channel.unbindStore(store);const diagnostics_channel =require('node:diagnostics_channel');const {AsyncLocalStorage } =require('node:async_hooks');const store =newAsyncLocalStorage();const channel = diagnostics_channel.channel('my-channel');channel.bindStore(store);channel.unbindStore(store);
channel.runStores(context, fn[, thisArg[, ...args]])#
context<any> Message to send to subscribers and bind to storesfn<Function> Handler to run within the entered storage contextthisArg<any> The receiver to be used for the function call....args<any> Optional arguments to pass to the function.
Applies the given data to any AsyncLocalStorage instances bound to the channelfor the duration of the given function, then publishes to the channel withinthe scope of that data is applied to the stores.
If a transform function was given tochannel.bindStore(store) it will beapplied to transform the message data before it becomes the context value forthe store. The prior storage context is accessible from within the transformfunction in cases where context linking is required.
The context applied to the store should be accessible in any async code whichcontinues from execution which began during the given function, howeverthere are some situations in whichcontext loss may occur.
import diagnostics_channelfrom'node:diagnostics_channel';import {AsyncLocalStorage }from'node:async_hooks';const store =newAsyncLocalStorage();const channel = diagnostics_channel.channel('my-channel');channel.bindStore(store,(message) => {const parent = store.getStore();returnnewSpan(message, parent);});channel.runStores({some:'message' },() => { store.getStore();// Span({ some: 'message' })});const diagnostics_channel =require('node:diagnostics_channel');const {AsyncLocalStorage } =require('node:async_hooks');const store =newAsyncLocalStorage();const channel = diagnostics_channel.channel('my-channel');channel.bindStore(store,(message) => {const parent = store.getStore();returnnewSpan(message, parent);});channel.runStores({some:'message' },() => { store.getStore();// Span({ some: 'message' })});
Class:TracingChannel#
The classTracingChannel is a collection ofTracingChannel Channels whichtogether express a single traceable action. It is used to formalize andsimplify the process of producing events for tracing application flow.diagnostics_channel.tracingChannel() is used to construct aTracingChannel. As withChannel it is recommended to create and reuse asingleTracingChannel at the top-level of the file rather than creating themdynamically.
tracingChannel.subscribe(subscribers)#
subscribers<Object> Set ofTracingChannel Channels subscribersstart<Function> Thestartevent subscriberend<Function> Theendevent subscriberasyncStart<Function> TheasyncStartevent subscriberasyncEnd<Function> TheasyncEndevent subscribererror<Function> Theerrorevent subscriber
Helper to subscribe a collection of functions to the corresponding channels.This is the same as callingchannel.subscribe(onMessage) on each channelindividually.
import diagnostics_channelfrom'node:diagnostics_channel';const channels = diagnostics_channel.tracingChannel('my-channel');channels.subscribe({start(message) {// Handle start message },end(message) {// Handle end message },asyncStart(message) {// Handle asyncStart message },asyncEnd(message) {// Handle asyncEnd message },error(message) {// Handle error message },});const diagnostics_channel =require('node:diagnostics_channel');const channels = diagnostics_channel.tracingChannel('my-channel');channels.subscribe({start(message) {// Handle start message },end(message) {// Handle end message },asyncStart(message) {// Handle asyncStart message },asyncEnd(message) {// Handle asyncEnd message },error(message) {// Handle error message },});
tracingChannel.unsubscribe(subscribers)#
subscribers<Object> Set ofTracingChannel Channels subscribersstart<Function> Thestartevent subscriberend<Function> Theendevent subscriberasyncStart<Function> TheasyncStartevent subscriberasyncEnd<Function> TheasyncEndevent subscribererror<Function> Theerrorevent subscriber
- Returns:<boolean>
trueif all handlers were successfully unsubscribed,andfalseotherwise.
Helper to unsubscribe a collection of functions from the corresponding channels.This is the same as callingchannel.unsubscribe(onMessage) on each channelindividually.
import diagnostics_channelfrom'node:diagnostics_channel';const channels = diagnostics_channel.tracingChannel('my-channel');channels.unsubscribe({start(message) {// Handle start message },end(message) {// Handle end message },asyncStart(message) {// Handle asyncStart message },asyncEnd(message) {// Handle asyncEnd message },error(message) {// Handle error message },});const diagnostics_channel =require('node:diagnostics_channel');const channels = diagnostics_channel.tracingChannel('my-channel');channels.unsubscribe({start(message) {// Handle start message },end(message) {// Handle end message },asyncStart(message) {// Handle asyncStart message },asyncEnd(message) {// Handle asyncEnd message },error(message) {// Handle error message },});
tracingChannel.traceSync(fn[, context[, thisArg[, ...args]]])#
fn<Function> Function to wrap a trace aroundcontext<Object> Shared object to correlate events throughthisArg<any> The receiver to be used for the function call...args<any> Optional arguments to pass to the function- Returns:<any> The return value of the given function
Trace a synchronous function call. This will always produce astart eventandend event around the execution and may produce anerror eventif the given function throws an error. This will run the given function usingchannel.runStores(context, ...) on thestart channel which ensures allevents should have any bound stores set to match this trace context.
To ensure only correct trace graphs are formed, events will only be publishedif subscribers are present prior to starting the trace. Subscriptions which areadded after the trace begins will not receive future events from that trace,only future traces will be seen.
import diagnostics_channelfrom'node:diagnostics_channel';const channels = diagnostics_channel.tracingChannel('my-channel');channels.traceSync(() => {// Do something}, {some:'thing',});const diagnostics_channel =require('node:diagnostics_channel');const channels = diagnostics_channel.tracingChannel('my-channel');channels.traceSync(() => {// Do something}, {some:'thing',});
tracingChannel.tracePromise(fn[, context[, thisArg[, ...args]]])#
fn<Function> Promise-returning function to wrap a trace aroundcontext<Object> Shared object to correlate trace events throughthisArg<any> The receiver to be used for the function call...args<any> Optional arguments to pass to the function- Returns:<Promise> Chained from promise returned by the given function
Trace a promise-returning function call. This will always produce astart event andend event around the synchronous portion of thefunction execution, and will produce anasyncStart event andasyncEnd event when a promise continuation is reached. It may alsoproduce anerror event if the given function throws an error or thereturned promise rejects. This will run the given function usingchannel.runStores(context, ...) on thestart channel which ensures allevents should have any bound stores set to match this trace context.
To ensure only correct trace graphs are formed, events will only be publishedif subscribers are present prior to starting the trace. Subscriptions which areadded after the trace begins will not receive future events from that trace,only future traces will be seen.
import diagnostics_channelfrom'node:diagnostics_channel';const channels = diagnostics_channel.tracingChannel('my-channel');channels.tracePromise(async () => {// Do something}, {some:'thing',});const diagnostics_channel =require('node:diagnostics_channel');const channels = diagnostics_channel.tracingChannel('my-channel');channels.tracePromise(async () => {// Do something}, {some:'thing',});
tracingChannel.traceCallback(fn[, position[, context[, thisArg[, ...args]]]])#
fn<Function> callback using function to wrap a trace aroundposition<number> Zero-indexed argument position of expected callback(defaults to last argument ifundefinedis passed)context<Object> Shared object to correlate trace events through (defaultsto{}ifundefinedis passed)thisArg<any> The receiver to be used for the function call...args<any> arguments to pass to the function (must include the callback)- Returns:<any> The return value of the given function
Trace a callback-receiving function call. The callback is expected to followthe error as first arg convention typically used. This will always produce astart event andend event around the synchronous portion of thefunction execution, and will produce aasyncStart event andasyncEnd event around the callback execution. It may also produce anerror event if the given function throws or the first argument passed tothe callback is set. This will run the given function usingchannel.runStores(context, ...) on thestart channel which ensures allevents should have any bound stores set to match this trace context.
To ensure only correct trace graphs are formed, events will only be publishedif subscribers are present prior to starting the trace. Subscriptions which areadded after the trace begins will not receive future events from that trace,only future traces will be seen.
import diagnostics_channelfrom'node:diagnostics_channel';const channels = diagnostics_channel.tracingChannel('my-channel');channels.traceCallback((arg1, callback) => {// Do somethingcallback(null,'result');},1, {some:'thing',}, thisArg, arg1, callback);const diagnostics_channel =require('node:diagnostics_channel');const channels = diagnostics_channel.tracingChannel('my-channel');channels.traceCallback((arg1, callback) => {// Do somethingcallback(null,'result');},1, {some:'thing',}, thisArg, arg1, callback);
The callback will also be run withchannel.runStores(context, ...) whichenables context loss recovery in some cases.
import diagnostics_channelfrom'node:diagnostics_channel';import {AsyncLocalStorage }from'node:async_hooks';const channels = diagnostics_channel.tracingChannel('my-channel');const myStore =newAsyncLocalStorage();// The start channel sets the initial store data to something// and stores that store data value on the trace context objectchannels.start.bindStore(myStore,(data) => {const span =newSpan(data); data.span = span;return span;});// Then asyncStart can restore from that data it stored previouslychannels.asyncStart.bindStore(myStore,(data) => {return data.span;});const diagnostics_channel =require('node:diagnostics_channel');const {AsyncLocalStorage } =require('node:async_hooks');const channels = diagnostics_channel.tracingChannel('my-channel');const myStore =newAsyncLocalStorage();// The start channel sets the initial store data to something// and stores that store data value on the trace context objectchannels.start.bindStore(myStore,(data) => {const span =newSpan(data); data.span = span;return span;});// Then asyncStart can restore from that data it stored previouslychannels.asyncStart.bindStore(myStore,(data) => {return data.span;});
tracingChannel.hasSubscribers#
- Returns:<boolean>
trueif any of the individual channels has a subscriber,falseif not.
This is a helper method available on aTracingChannel instance to check ifany of theTracingChannel Channels have subscribers. Atrue is returned ifany of them have at least one subscriber, afalse is returned otherwise.
import diagnostics_channelfrom'node:diagnostics_channel';const channels = diagnostics_channel.tracingChannel('my-channel');if (channels.hasSubscribers) {// Do something}const diagnostics_channel =require('node:diagnostics_channel');const channels = diagnostics_channel.tracingChannel('my-channel');if (channels.hasSubscribers) {// Do something}
TracingChannel Channels#
A TracingChannel is a collection of several diagnostics_channels representingspecific points in the execution lifecycle of a single traceable action. Thebehavior is split into five diagnostics_channels consisting ofstart,end,asyncStart,asyncEnd, anderror. A single traceable action willshare the same event object between all events, this can be helpful formanaging correlation through a weakmap.
These event objects will be extended withresult orerror values whenthe task "completes". In the case of a synchronous task theresult will bethe return value and theerror will be anything thrown from the function.With callback-based async functions theresult will be the second argumentof the callback while theerror will either be a thrown error visible in theend event or the first callback argument in either of theasyncStart orasyncEnd events.
To ensure only correct trace graphs are formed, events should only be publishedif subscribers are present prior to starting the trace. Subscriptions which areadded after the trace begins should not receive future events from that trace,only future traces will be seen.
Tracing channels should follow a naming pattern of:
tracing:module.class.method:startortracing:module.function:starttracing:module.class.method:endortracing:module.function:endtracing:module.class.method:asyncStartortracing:module.function:asyncStarttracing:module.class.method:asyncEndortracing:module.function:asyncEndtracing:module.class.method:errorortracing:module.function:error
start(event)#
- Name:
tracing:${name}:start
Thestart event represents the point at which a function is called. At thispoint the event data may contain function arguments or anything else availableat the very start of the execution of the function.
end(event)#
- Name:
tracing:${name}:end
Theend event represents the point at which a function call returns a value.In the case of an async function this is when the promise returned not when thefunction itself makes a return statement internally. At this point, if thetraced function was synchronous theresult field will be set to the returnvalue of the function. Alternatively, theerror field may be present torepresent any thrown errors.
It is recommended to listen specifically to theerror event to track errorsas it may be possible for a traceable action to produce multiple errors. Forexample, an async task which fails may be started internally before the syncpart of the task then throws an error.
asyncStart(event)#
- Name:
tracing:${name}:asyncStart
TheasyncStart event represents the callback or continuation of a traceablefunction being reached. At this point things like callback arguments may beavailable, or anything else expressing the "result" of the action.
For callbacks-based functions, the first argument of the callback will beassigned to theerror field, if notundefined ornull, and the secondargument will be assigned to theresult field.
For promises, the argument to theresolve path will be assigned toresultor the argument to thereject path will be assign toerror.
It is recommended to listen specifically to theerror event to track errorsas it may be possible for a traceable action to produce multiple errors. Forexample, an async task which fails may be started internally before the syncpart of the task then throws an error.
asyncEnd(event)#
- Name:
tracing:${name}:asyncEnd
TheasyncEnd event represents the callback of an asynchronous functionreturning. It's not likely event data will change after theasyncStart event,however it may be useful to see the point where the callback completes.
error(event)#
- Name:
tracing:${name}:error
Theerror event represents any error produced by the traceable functioneither synchronously or asynchronously. If an error is thrown in thesynchronous portion of the traced function the error will be assigned to theerror field of the event and theerror event will be triggered. If an erroris received asynchronously through a callback or promise rejection it will alsobe assigned to theerror field of the event and trigger theerror event.
It is possible for a single traceable function call to produce errors multipletimes so this should be considered when consuming this event. For example, ifanother async task is triggered internally which fails and then the sync partof the function then throws and error twoerror events will be emitted, onefor the sync error and one for the async error.
Built-in Channels#
Console#
Event:'console.log'#
args<any[]>
Emitted whenconsole.log() is called. Receives and array of the argumentspassed toconsole.log().
Event:'console.info'#
args<any[]>
Emitted whenconsole.info() is called. Receives and array of the argumentspassed toconsole.info().
Event:'console.debug'#
args<any[]>
Emitted whenconsole.debug() is called. Receives and array of the argumentspassed toconsole.debug().
HTTP#
Event:'http.client.request.created'#
request<http.ClientRequest>
Emitted when client creates a request object.Unlikehttp.client.request.start, this event is emitted before the request has been sent.
Event:'http.client.request.error'#
request<http.ClientRequest>error<Error>
Emitted when an error occurs during a client request.
Event:'http.client.response.finish'#
request<http.ClientRequest>response<http.IncomingMessage>
Emitted when client receives a response.
Event:'http.server.request.start'#
request<http.IncomingMessage>response<http.ServerResponse>socket<net.Socket>server<http.Server>
Emitted when server receives a request.
Event:'http.server.response.created'#
request<http.IncomingMessage>response<http.ServerResponse>
Emitted when server creates a response.The event is emitted before the response is sent.
Event:'http.server.response.finish'#
request<http.IncomingMessage>response<http.ServerResponse>socket<net.Socket>server<http.Server>
Emitted when server sends a response.
HTTP/2#
Event:'http2.client.stream.created'#
stream<ClientHttp2Stream>headers<HTTP/2 Headers Object>
Emitted when a stream is created on the client.
Event:'http2.client.stream.start'#
stream<ClientHttp2Stream>headers<HTTP/2 Headers Object>
Emitted when a stream is started on the client.
Event:'http2.client.stream.error'#
stream<ClientHttp2Stream>error<Error>
Emitted when an error occurs during the processing of a stream on the client.
Event:'http2.client.stream.finish'#
stream<ClientHttp2Stream>headers<HTTP/2 Headers Object>flags<number>
Emitted when a stream is received on the client.
Event:'http2.client.stream.bodyChunkSent'#
stream<ClientHttp2Stream>writev<boolean>data<Buffer> |<string> |<Buffer[]> |<Object[]>encoding<string>
Emitted when a chunk of the client stream body is being sent.
Event:'http2.client.stream.bodySent'#
stream<ClientHttp2Stream>
Emitted after the client stream body has been fully sent.
Event:'http2.client.stream.close'#
stream<ClientHttp2Stream>
Emitted when a stream is closed on the client. The HTTP/2 error code used whenclosing the stream can be retrieved using thestream.rstCode property.
Event:'http2.server.stream.created'#
stream<ServerHttp2Stream>headers<HTTP/2 Headers Object>
Emitted when a stream is created on the server.
Event:'http2.server.stream.start'#
stream<ServerHttp2Stream>headers<HTTP/2 Headers Object>
Emitted when a stream is started on the server.
Event:'http2.server.stream.error'#
stream<ServerHttp2Stream>error<Error>
Emitted when an error occurs during the processing of a stream on the server.
Event:'http2.server.stream.finish'#
stream<ServerHttp2Stream>headers<HTTP/2 Headers Object>flags<number>
Emitted when a stream is sent on the server.
Event:'http2.server.stream.close'#
stream<ServerHttp2Stream>
Emitted when a stream is closed on the server. The HTTP/2 error code used whenclosing the stream can be retrieved using thestream.rstCode property.
Modules#
Event:'module.require.start'#
event<Object> containing the following propertiesidArgument passed torequire(). Module name.parentFilenameName of the module that attempted to require(id).
Emitted whenrequire() is executed. Seestart event.
Event:'module.require.end'#
event<Object> containing the following propertiesidArgument passed torequire(). Module name.parentFilenameName of the module that attempted to require(id).
Emitted when arequire() call returns. Seeend event.
Event:'module.require.error'#
event<Object> containing the following propertiesidArgument passed torequire(). Module name.parentFilenameName of the module that attempted to require(id).
error<Error>
Emitted when arequire() throws an error. Seeerror event.
Event:'module.import.asyncStart'#
event<Object> containing the following propertiesidArgument passed toimport(). Module name.parentURLURL object of the module that attempted to import(id).
Emitted whenimport() is invoked. SeeasyncStart event.
Event:'module.import.asyncEnd'#
event<Object> containing the following propertiesidArgument passed toimport(). Module name.parentURLURL object of the module that attempted to import(id).
Emitted whenimport() has completed. SeeasyncEnd event.
Event:'module.import.error'#
event<Object> containing the following propertiesidArgument passed toimport(). Module name.parentURLURL object of the module that attempted to import(id).
error<Error>
Emitted when aimport() throws an error. Seeerror event.
NET#
Event:'net.client.socket'#
socket<net.Socket> |<tls.TLSSocket>
Emitted when a new TCP or pipe client socket connection is created.
Event:'tracing:net.server.listen:asyncStart'#
server<net.Server>options<Object>
Emitted whennet.Server.listen() is invoked, before the port or pipe is actually setup.
Event:'tracing:net.server.listen:asyncEnd'#
server<net.Server>
Emitted whennet.Server.listen() has completed and thus the server is ready to accept connection.
Event:'tracing:net.server.listen:error'#
server<net.Server>error<Error>
Emitted whennet.Server.listen() is returning an error.