File tree Expand file tree Collapse file tree 5 files changed +57
-0
lines changed Expand file tree Collapse file tree 5 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,8 @@ The available categories are:
40
40
measures and marks.
41
41
* ` node.perf.timerify ` : Enables capture of only Performance API timerify
42
42
measurements.
43
+ * ` node.process.sync ` : Enables capture of trace data for the sync APIs of
44
+ process module.
43
45
* ` node.promises.rejections ` : Enables capture of trace data tracking the number
44
46
of unhandled Promise rejections and handled-after-rejections.
45
47
* ` node.vm.script ` : Enables capture of trace data for the ` node:vm ` module's
Original file line number Diff line number Diff line change @@ -190,6 +190,7 @@ DispatchResponse TracingAgent::getCategories(
190
190
categories_list->addItem (" node.perf" );
191
191
categories_list->addItem (" node.perf.timerify" );
192
192
categories_list->addItem (" node.perf.usertiming" );
193
+ categories_list->addItem (" node.process.sync" );
193
194
categories_list->addItem (" node.promises.rejections" );
194
195
categories_list->addItem (" node.threadpoolwork.async" );
195
196
categories_list->addItem (" node.threadpoolwork.sync" );
Original file line number Diff line number Diff line change 24
24
#include " env-inl.h"
25
25
#include " node_internals.h"
26
26
#include " string_bytes.h"
27
+ #include " tracing/trace_event.h"
27
28
#include " util-inl.h"
28
29
29
30
#include < cstring>
@@ -514,8 +515,21 @@ Maybe<bool> SyncProcessRunner::TryInitializeAndRunLoop(Local<Value> options) {
514
515
}
515
516
}
516
517
}
518
+ if (*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED (
519
+ TRACING_CATEGORY_NODE2 (process, sync)) != 0 ) {
520
+ TRACE_EVENT_BEGIN1 (TRACING_CATEGORY_NODE2 (process, sync),
521
+ " spawnSync" ,
522
+ " file" ,
523
+ TRACE_STR_COPY (uv_process_options_.file ));
524
+ }
517
525
518
526
r = uv_run (uv_loop_, UV_RUN_DEFAULT);
527
+
528
+ if (*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED (
529
+ TRACING_CATEGORY_NODE2 (process, sync)) != 0 ) {
530
+ TRACE_EVENT_END0 (TRACING_CATEGORY_NODE2 (process, sync), " spawnSync" );
531
+ }
532
+
519
533
if (r < 0 )
520
534
// We can't handle uv_run failure.
521
535
ABORT ();
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ async function test() {
58
58
'node.perf' ,
59
59
'node.perf.timerify' ,
60
60
'node.perf.usertiming' ,
61
+ 'node.process.sync' ,
61
62
'node.promises.rejections' ,
62
63
'node.threadpoolwork.async' ,
63
64
'node.threadpoolwork.sync' ,
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ require ( '../common' ) ;
3
+ const assert = require ( 'assert' ) ;
4
+ const cp = require ( 'child_process' ) ;
5
+ const fs = require ( 'fs' ) ;
6
+ const path = require ( 'path' ) ;
7
+ const tmpdir = require ( '../common/tmpdir' ) ;
8
+
9
+ if ( process . env . isChild === '1' ) {
10
+ cp . execFileSync ( 'node' , [ '-e' , '' ] ) ;
11
+ cp . execSync ( 'node' , [ '-e' , '' ] ) ;
12
+ cp . spawnSync ( 'node' , [ '-e' , '' ] ) ;
13
+ return ;
14
+ }
15
+
16
+ tmpdir . refresh ( ) ;
17
+ const FILE_NAME = path . join ( tmpdir . path , 'node_trace.1.log' ) ;
18
+
19
+ cp . spawnSync ( process . execPath ,
20
+ [
21
+ '--trace-events-enabled' ,
22
+ '--trace-event-categories' , 'node.process.sync' ,
23
+ __filename ,
24
+ ] ,
25
+ {
26
+ cwd : tmpdir . path ,
27
+ env : {
28
+ ...process . env ,
29
+ isChild : '1' ,
30
+ } ,
31
+ } ) ;
32
+
33
+ assert ( fs . existsSync ( FILE_NAME ) ) ;
34
+ const data = fs . readFileSync ( FILE_NAME ) ;
35
+ const traces = JSON . parse ( data . toString ( ) ) . traceEvents ;
36
+ assert ( traces . length > 0 ) ;
37
+ const count = traces . filter ( ( item ) => item . name === 'spawnSync' ) . length ;
38
+ // Two begin, Two end
39
+ assert . strictEqual ( count === 3 * 2 , true ) ;
You can’t perform that action at this time.
0 commit comments