-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
Allow the user to specify the filepath for the trace_events log file using a template string. PR-URL: #18480 Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,6 +156,10 @@ Enable the collection of trace event tracing information. | |
A comma-separated list of categories that should be traced when trace event tracing is enabled using | ||
.Fl -trace-events-enabled . | ||
. | ||
.It Fl -trace-event-file-pattern Ar pattern | ||
Template string specifying the filepath for the trace event data, it | ||
supports \fB${rotation}\fR and \fB${pid}\fR. | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Alhadis
Contributor
|
||
. | ||
.It Fl -zero-fill-buffers | ||
Automatically zero-fills all newly allocated Buffer and SlowBuffer instances. | ||
. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,6 +192,8 @@ static node_module* modlist_linked; | |
static node_module* modlist_addon; | ||
static bool trace_enabled = false; | ||
static std::string trace_enabled_categories; // NOLINT(runtime/string) | ||
static std::string trace_file_pattern = // NOLINT(runtime/string) | ||
"node_trace.${rotation}.log"; | ||
static bool abort_on_uncaught_exception = false; | ||
|
||
// Bit flag used to track security reverts (see node_revert.h) | ||
|
@@ -275,7 +277,7 @@ static struct { | |
#if NODE_USE_V8_PLATFORM | ||
void Initialize(int thread_pool_size) { | ||
if (trace_enabled) { | ||
tracing_agent_.reset(new tracing::Agent()); | ||
tracing_agent_.reset(new tracing::Agent(trace_file_pattern)); | ||
platform_ = new NodePlatform(thread_pool_size, | ||
tracing_agent_->GetTracingController()); | ||
V8::InitializePlatform(platform_); | ||
|
@@ -3422,6 +3424,10 @@ static void PrintHelp() { | |
" --trace-events-enabled track trace events\n" | ||
" --trace-event-categories comma separated list of trace event\n" | ||
" categories to record\n" | ||
" --trace-event-file-pattern Template string specifying the\n" | ||
" filepath for the trace-events data, it\n" | ||
" supports ${rotation} and ${pid}\n" | ||
" log-rotation id. %%2$u is the pid.\n" | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
AndreasMadsen
Author
Member
|
||
" --track-heap-objects track heap object allocations for heap " | ||
"snapshots\n" | ||
" --prof-process process v8 profiler output generated\n" | ||
|
@@ -3550,6 +3556,7 @@ static void CheckIfAllowedInEnv(const char* exe, bool is_env, | |
"--no-force-async-hooks-checks", | ||
"--trace-events-enabled", | ||
"--trace-event-categories", | ||
"--trace-event-file-pattern", | ||
"--track-heap-objects", | ||
"--zero-fill-buffers", | ||
"--v8-pool-size", | ||
|
@@ -3701,6 +3708,14 @@ static void ParseArgs(int* argc, | |
} | ||
args_consumed += 1; | ||
trace_enabled_categories = categories; | ||
} else if (strcmp(arg, "--trace-event-file-pattern") == 0) { | ||
const char* file_pattern = argv[index + 1]; | ||
if (file_pattern == nullptr) { | ||
fprintf(stderr, "%s: %s requires an argument\n", argv[0], arg); | ||
exit(9); | ||
} | ||
args_consumed += 1; | ||
trace_file_pattern = file_pattern; | ||
} else if (strcmp(arg, "--track-heap-objects") == 0) { | ||
track_heap_objects = true; | ||
} else if (strcmp(arg, "--throw-deprecation") == 0) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const tmpdir = require('../common/tmpdir'); | ||
const assert = require('assert'); | ||
const cp = require('child_process'); | ||
const fs = require('fs'); | ||
|
||
tmpdir.refresh(); | ||
process.chdir(tmpdir.path); | ||
|
||
const CODE = | ||
'setTimeout(() => { for (var i = 0; i < 100000; i++) { "test" + i } }, 1)'; | ||
|
||
const proc = cp.spawn(process.execPath, [ | ||
'--trace-events-enabled', | ||
'--trace-event-file-pattern', | ||
// eslint-disable-next-line no-template-curly-in-string | ||
'${pid}-${rotation}-${pid}-${rotation}.tracing.log', | ||
'-e', CODE | ||
]); | ||
|
||
proc.once('exit', common.mustCall(() => { | ||
const expectedFilename = `${proc.pid}-1-${proc.pid}-1.tracing.log`; | ||
|
||
assert(common.fileExists(expectedFilename)); | ||
fs.readFile(expectedFilename, common.mustCall((err, data) => { | ||
const traces = JSON.parse(data.toString()).traceEvents; | ||
assert(traces.length > 0); | ||
})); | ||
})); |
Random Roff tip-of-the-week: It's better to use
\fP
instead of\fR
when undoing font changes, as the latter restores the font (formatting state) being used prior to the last font change.Meaning of each letter:
\fP
: Previous font\fR
: Roman (as opposed to Italic, Bold, and Bold Italic). You can also just think of it as standing for "Regular font" too. =)