@@ -7,20 +7,18 @@ const {
77 Symbol,
88} = primordials ;
99
10- const { trace } = internalBinding ( 'trace_events' ) ;
10+ const {
11+ trace,
12+ nodeTraceEventCategory,
13+ kAsyncBegin,
14+ kAsyncEnd,
15+ kSyncBegin,
16+ kSyncEnd,
17+ } = require ( 'internal/trace_events' ) ;
1118const async_wrap = internalBinding ( 'async_wrap' ) ;
1219const async_hooks = require ( 'async_hooks' ) ;
13- const {
14- CHAR_LOWERCASE_B ,
15- CHAR_LOWERCASE_E ,
16- } = require ( 'internal/constants' ) ;
1720
18- // Use small letters such that chrome://tracing groups by the name.
19- // The behavior is not only useful but the same as the events emitted using
20- // the specific C++ macros.
21- const kBeforeEvent = CHAR_LOWERCASE_B ;
22- const kEndEvent = CHAR_LOWERCASE_E ;
23- const kTraceEventCategory = 'node,node.async_hooks' ;
21+ const kTraceEventCategory = nodeTraceEventCategory ( 'node.async_hooks' ) ;
2422
2523const kEnabled = Symbol ( 'enabled' ) ;
2624
@@ -45,7 +43,7 @@ function createHook() {
4543 if ( nativeProviders . has ( type ) ) return ;
4644
4745 typeMemory . set ( asyncId , type ) ;
48- trace ( kBeforeEvent , kTraceEventCategory ,
46+ trace ( kAsyncBegin , kTraceEventCategory ,
4947 type , asyncId ,
5048 {
5149 triggerAsyncId,
@@ -57,21 +55,21 @@ function createHook() {
5755 const type = typeMemory . get ( asyncId ) ;
5856 if ( type === undefined ) return ;
5957
60- trace ( kBeforeEvent , kTraceEventCategory , `${ type } _CALLBACK` , asyncId ) ;
58+ trace ( kSyncBegin , kTraceEventCategory , `${ type } _CALLBACK` , asyncId ) ;
6159 } ,
6260
6361 after ( asyncId ) {
6462 const type = typeMemory . get ( asyncId ) ;
6563 if ( type === undefined ) return ;
6664
67- trace ( kEndEvent , kTraceEventCategory , `${ type } _CALLBACK` , asyncId ) ;
65+ trace ( kSyncEnd , kTraceEventCategory , `${ type } _CALLBACK` , asyncId ) ;
6866 } ,
6967
7068 destroy ( asyncId ) {
7169 const type = typeMemory . get ( asyncId ) ;
7270 if ( type === undefined ) return ;
7371
74- trace ( kEndEvent , kTraceEventCategory , type , asyncId ) ;
72+ trace ( kAsyncEnd , kTraceEventCategory , type , asyncId ) ;
7573
7674 // Cleanup asyncId to type map
7775 typeMemory . delete ( asyncId ) ;
0 commit comments