Search the reference...
/
BuildDocsReferenceGuidesBlogDiscord/node:diagnostics_channel/TracingChannelPasyncEndPasyncStartCoconstructorPendPerrorPhasSubscribersPstartMsubscribeMtraceCallbackMtracePromiseMtraceSyncMunsubscribeclass
diagnostics_channel.TracingChannelclass TracingChannelStoreType = unknown, ContextType extends object = {}>The class TracingChannel is a collection of TracingChannel Channels which together express a single traceable action. It is used to formalize and simplify the process of producing events for tracing application flow. tracingChannel is used to construct a TracingChannel. As with Channel it is recommended to create and reuse a single TracingChannel at the top-level of the file rather than creating them dynamically.asyncEnd: ChannelStoreType, ContextType>asyncStart: ChannelStoreType, ContextType>end: ChannelStoreType, ContextType>error: ChannelStoreType, ContextType>readonly hasSubscribers: booleantrue if any of the individual channels has a subscriber, false if not.This is a helper method available on a TracingChannel instance to check if any of the TracingChannel Channels have subscribers. A true is returned if any of them have at least one subscriber, a false is returned otherwise.const diagnostics_channel = require('node:diagnostics_channel'); const channels = diagnostics_channel.tracingChannel('my-channel'); if (channels.hasSubscribers) { // Do something } start: ChannelStoreType, ContextType>subscribe(subscribers: TracingChannelSubscribersContextType>): void;Helper to subscribe a collection of functions to the corresponding channels. This is the same as calling channel.subscribe(onMessage) on each channel individually.import diagnostics_channel from '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 }, }); @param subscribersSet of TracingChannel Channels subscribers { // Do something callback(null, 'result'); }, 1, { some: 'thing', }, thisArg, arg1, callback); ``` The callback will also be run with `channel.runStores(context, ...)` which enables context loss recovery in some cases. 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'; import { AsyncLocalStorage } from 'node:async_hooks'; const channels = diagnostics_channel.tracingChannel('my-channel'); const myStore = new AsyncLocalStorage(); // The start channel sets the initial store data to something // and stores that store data value on the trace context object channels.start.bindStore(myStore, (data) => { const span = new Span(data); data.span = span; return span; }); // Then asyncStart can restore from that data it stored previously channels.asyncStart.bindStore(myStore, (data) => { return data.span; }); ```" data-algolia-static="false" data-algolia-merged="false" data-type="Method">traceCallbackThisArg = any, Args extends any[] = any[], Result = any>(fn: (this: ThisArg, ...args: Args) => Result,position?: number,context?: ContextType,thisArg?: ThisArg,...args: Args): Result;Trace a callback-receiving function call. This will always produce a start event and end event around the synchronous portion of the function execution, and will produce a asyncStart event and asyncEnd event around the callback execution. 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.The position will be -1 by default to indicate the final argument should be used as the callback.import diagnostics_channel from 'node:diagnostics_channel'; const channels = diagnostics_channel.tracingChannel('my-channel'); channels.traceCallback((arg1, callback) => { // Do something callback(null, 'result'); }, 1, { some: 'thing', }, thisArg, arg1, callback); The callback will also be run with channel.runStores(context, ...) which enables context loss recovery in some cases.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'; import { AsyncLocalStorage } from 'node:async_hooks'; const channels = diagnostics_channel.tracingChannel('my-channel'); const myStore = new AsyncLocalStorage(); // The start channel sets the initial store data to something // and stores that store data value on the trace context object channels.start.bindStore(myStore, (data) => { const span = new Span(data); data.span = span; return span; }); // Then asyncStart can restore from that data it stored previously channels.asyncStart.bindStore(myStore, (data) => { return data.span; }); @param fncallback using function to wrap a trace around@param positionZero-indexed argument position of expected callback@param contextShared object to correlate trace events through@param thisArgThe receiver to be used for the function call@param argsOptional arguments to pass to the function@returnsThe return value of the given function { // Do something }, { some: 'thing', }); ```" data-algolia-static="false" data-algolia-merged="false" data-type="Method">tracePromiseThisArg = any, Args extends any[] = any[], Result = any>(fn: (this: ThisArg, ...args: Args) => PromiseResult>,context?: ContextType,thisArg?: ThisArg,...args: Args): PromiseResult>;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.import diagnostics_channel from 'node:diagnostics_channel'; const channels = diagnostics_channel.tracingChannel('my-channel'); channels.tracePromise(async () => { // Do something }, { some: 'thing', }); @param fnPromise-returning function to wrap a trace around@param contextShared object to correlate trace events through@param thisArgThe receiver to be used for the function call@param argsOptional arguments to pass to the function@returnsChained from promise returned by the given function { // Do something }, { some: 'thing', }); ```" data-algolia-static="false" data-algolia-merged="false" data-type="Method">traceSyncThisArg = any, Args extends any[] = any[], Result = any>(fn: (this: ThisArg, ...args: Args) => Result,context?: ContextType,thisArg?: ThisArg,...args: Args): Result;Trace 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', }); @param fnFunction to wrap a trace around@param contextShared object to correlate events through@param thisArgThe receiver to be used for the function call@param argsOptional arguments to pass to the function@returnsThe return value of the given functionunsubscribe(subscribers: TracingChannelSubscribersContextType>): void;Helper to unsubscribe a collection of functions from the corresponding channels. This is the same as calling channel.unsubscribe(onMessage) on each channel individually.import diagnostics_channel from '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 }, }); @param subscribersSet of TracingChannel Channels subscribers@returnstrue if all handlers were successfully unsubscribed, and false otherwise.Resources
ReferenceDocsGuidesDiscordMerch StoreGitHubBlogToolkit
RuntimePackage managerTest runnerBundlerPackage runnerProject
Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San FranciscoWe're hiring →智能索引记录
-
2026-03-02 14:06:38
综合导航
成功
标题:Bringing Street Art Indoors with OLED Technology LG Global
简介:To mark the launch of LG G1 series OLED TV with Gallery Desi
-
2026-03-02 16:40:47
综合导航
成功
标题:† Valeur. World English Historical Dictionary
简介:† Valeur. World English Historical Dictionary
-
2026-03-02 06:32:25
综合导航
成功
标题:主母被听心声,满门炮灰摆烂吃瓜_一键难求_第514章 大结局_全本小说网
简介:全本小说网提供主母被听心声,满门炮灰摆烂吃瓜(一键难求)第514章 大结局在线阅读,所有小说均免费阅读,努力打造最干净的
-
2026-03-02 11:27:50
综合导航
成功
标题:Schaeffler Germany
简介:Schaeffler has been driving forward groundbreaking invention
-
2026-03-02 06:37:05
综合导航
成功
标题:アカウントを削除する LG it LGV36 オンラインマニュアル(取扱説明書) au
简介:auのスマートフォン「LG it(エルジー イット)LGV36」Android8.1版のオンラインマニュアル(取扱説明書
-
2026-03-02 16:15:11
综合导航
成功
标题:æºè½çæ¼é³_æºè½çææ_æºè½çç¹ä½_è¯ç»ç½
简介:è¯ç»ç½æºè½é¢é,ä»ç»æºè½,æºè½çæ¼é³,æºè½æ¯
-
2026-03-02 14:36:13
综合导航
成功
标题:中智集团2026校园招聘:报名条件+报名流程!-高顿
简介:中智集团2026校园招聘报名条件有哪些?主要招聘2026届国内外优秀高校毕业生;需要本科及以上学历,并且要求具备良好的语
-
2026-03-02 10:35:20
综合导航
成功
标题:a16z co-creates money, AI Bot issues coins, Meme coins have reached a new dimension Bee Network
简介:Original author: TechFlow Meme coins have rolled into a n
-
2026-03-02 10:46:23
图片素材
成功
标题:六年级读后感作文550字 六年级550字读后感作文大全-作文网
简介:作文网优秀六年级读后感550字作文大全,包含六年级读后感550字作文素材,六年级读后感550字作文题目、美文范文,作文网
-
2026-03-02 11:00:37
综合导航
成功
标题:Air Hockey - Play Air Hockey Game Online Free
简介:Play Air Hockey game online for free on YAD. The game is pla
-
2026-03-02 16:42:04
综合导航
成功
标题:1 Click 1 Line 1 Pop - Play The Free Mobile Game Online
简介:1 Click 1 Line 1 Pop - click to play online. 1 Click 1 Line
-
2026-03-02 14:49:20
教育培训
成功
标题:【实用】高中作文汇总7篇
简介:在日常生活或是工作学习中,大家对作文都再熟悉不过了吧,作文是通过文字来表达一个主题意义的记叙方法。如何写一篇有思想、有文
-
2026-03-02 09:58:42
旅游出行
成功
标题:云龙谷景区招聘_德化云龙谷旅游发展有限公司招聘_电话_地址 _【官方】
简介:云龙谷景区招聘,德化云龙谷旅游发展有限公司招聘,公司在福建省泉州市德化县国宝乡206省道旁云龙谷景区,招聘岗位详情。
-
2026-03-02 12:26:13
图片素材
成功
标题:交谈的作文 描写交谈的作文 关于交谈的作文 素材-作文网
简介:作文网精选关于交谈的作文,包含交谈的作文素材,关于交谈的作文题目,以交谈为话题的作文大全,作文网原创名师点评,欢迎投稿!
-
2026-03-02 14:56:53
综合导航
成功
标题:Blog PIP - PIP Ocala, FL
简介:Track our weekly updates in interesting information with PIP
-
2026-03-02 13:27:41
综合导航
成功
标题:TGE is launched on Binance Wallet, CUDIS Three Horses are launched simultaneously, and the crypto health track has usher Bee Network
简介:Original Odaily Planet Daily ( @OdailyChina ) Author: Wen
-
2026-03-02 16:58:00
综合导航
成功
标题:New thinking on public chain valuation: L1 premium is in doubt, ETHs sovereignty is questioned Bee Network
简介:Original author: taetaehoho Original translation: TechFlow
-
2026-03-02 16:38:18
综合导航
成功
标题:第六百零九章 一根笔_诅咒之龙_路过的穿越者_新笔趣阁(56xu.com)
简介:诅咒之龙无防盗章节,作者路过的穿越者,第六百零九章 一根笔内容简要:死亡魔女的尸体目前主要考虑是如何更好地封存,这种封存
-
2026-03-02 16:36:42
综合导航
成功
标题:The Traffic Secrets Ignored by 99% of Web3 Creators Bee Network
简介:Original article translated by: Deep Tide TechFlow Most Web
-
2026-03-02 16:46:40
综合导航
成功
标题:Letter from the founder of Figure, the first RWA stock: DeFi will eventually become the mainstream way of asset financin Bee Network
简介:Original translation: Zhou, ChainCatcher Figure, a blockcha
-
2026-03-02 10:48:58
新闻资讯
成功
标题:【三层农村住宅设计图家居】_别墅设计网
简介:三层农村住宅设计图家居:为您提供最好的三层农村住宅设计图相关资讯及内容!了解三层农村住宅设计图怎么样知识,尽在别墅设计网
-
2026-03-02 16:39:28
综合导航
成功
标题:äºå¹²çæ¼é³_äºå¹²çææ_äºå¹²çç¹ä½_è¯ç»ç½
简介:è¯ç»ç½äºå¹²é¢é,ä»ç»äºå¹²,äºå¹²çæ¼é³,äºå¹²æ¯
-
2026-03-02 10:46:38
综合导航
成功
标题:H&M lance une collection pour Coachella
简介:Seulement quelques jours après avoir découvert la programmat
-
2026-03-02 13:08:38
视频影音
成功
标题:逆袭从签到神级姐姐开始第59集河马短剧_在线播放[高清流畅]_爽文短剧
简介:爽文短剧_逆袭从签到神级姐姐开始剧情介绍:逆袭从签到神级姐姐开始是由内详执导,内详等人主演的,于2025年上映,该都市讲
-
2026-03-02 14:06:00
教育培训
成功
标题:【精华】中秋节的作文800字汇总四篇
简介:在日常学习、工作或生活中,大家都不可避免地要接触到作文吧,根据写作命题的特点,作文可以分为命题作文和非命题作文。你所见过
-
2026-03-02 10:03:05
综合导航
成功
标题:DUS Airport
简介:Weit über 100 Flugziele mit einem intenationalen Airline-Mix
-
2026-03-02 14:45:04
综合导航
成功
标题:Able-bodiedness. World English Historical Dictionary
简介:Able-bodiedness. World English Historical Dictionary
-
2026-03-02 13:54:50
综合导航
成功
标题:WTB MK2 Alternator + Bracket Bolts [Archive] - Toyota MR2 Message Board
简介:I
-
2026-03-02 13:58:14
教育培训
成功
标题:我的语文老师作文
简介:在日常学习、工作或生活中,大家都不可避免地要接触到作文吧,作文要求篇章结构完整,一定要避免无结尾作文的出现。如何写一篇有
-
2026-03-02 14:26:30
综合导航
成功
标题:安能摧眉折腰事权贵是谁最新章节_安能摧眉折腰事权贵是谁全文免费阅读-笔趣阁
简介:安能摧眉折腰事权贵是谁,安能摧眉折腰事权贵是谁全文免费阅读。安能摧眉折腰事权贵是谁是作家黑猫糖的最新其他小说大作,笔趣阁