Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2018-03-06 01:46:19 +0300
committerJames M Snell <jasnell@gmail.com>2018-03-09 19:09:41 +0300
commit1dd9c9787bcf08db022ee63ce633fc9d497720e6 (patch)
treea10c638dfd43b2ef784cc8431ecd68a58c3aeb1e /src/node_perf.cc
parent45277e23d5488dc11d705b850d310b4afb5085bb (diff)
src: add tracing category macros
Adds `TRACING_CATEGORY_NODE`, `TRACING_CATEGORY_NODE1` and `TRACING_CATEGORY_NODE2` helper macros for consistently building trace event category strings. For instance, `TRACING_CATEGORY_NODE2(foo, bar)` would generate the category string `node,node.foo,node.foo.bar`, such that... ``` TRACE_EVENT_NESTABLE_ASYNC_BEGIN0( TRACING_CATEGORY_NODE2(foo, bar), "baz", 1); ``` Would emit if trace events are enabled for categories: `node`, `node.foo`, or `node.foo.bar`. This allows a natural scoping down of what trace events a user may want to receive. Enabling the `node` category would receive everything Node.js produces. PR-URL: https://github.com/nodejs/node/pull/19155 Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Diffstat (limited to 'src/node_perf.cc')
-rw-r--r--src/node_perf.cc21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/node_perf.cc b/src/node_perf.cc
index bf9746e429d..8260d78c329 100644
--- a/src/node_perf.cc
+++ b/src/node_perf.cc
@@ -135,7 +135,8 @@ void Mark(const FunctionCallbackInfo<Value>& args) {
(*marks)[*name] = now;
TRACE_EVENT_COPY_MARK_WITH_TIMESTAMP(
- "node.perf,node.perf.usertiming", *name, now / 1000);
+ TRACING_CATEGORY_NODE2(perf, usertiming),
+ *name, now / 1000);
PerformanceEntry entry(env, *name, "mark", now, now);
Local<Object> obj = entry.ToObject();
@@ -183,9 +184,11 @@ void Measure(const FunctionCallbackInfo<Value>& args) {
endTimestamp = startTimestamp;
TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0(
- "node.perf,node.perf.usertiming", *name, *name, startTimestamp / 1000);
+ TRACING_CATEGORY_NODE2(perf, usertiming),
+ *name, *name, startTimestamp / 1000);
TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TIMESTAMP0(
- "node.perf,node.perf.usertiming", *name, *name, endTimestamp / 1000);
+ TRACING_CATEGORY_NODE2(perf, usertiming),
+ *name, *name, endTimestamp / 1000);
PerformanceEntry entry(env, *name, "measure", startTimestamp, endTimestamp);
Local<Object> obj = entry.ToObject();
@@ -301,13 +304,15 @@ void TimerFunctionCall(const FunctionCallbackInfo<Value>& args) {
if (args.IsConstructCall()) {
start = PERFORMANCE_NOW();
TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0(
- "node.perf,node.perf.timerify", *name, *name, start / 1000);
+ TRACING_CATEGORY_NODE2(perf, timerify),
+ *name, *name, start / 1000);
v8::MaybeLocal<Object> ret = fn->NewInstance(context,
call_args.size(),
call_args.data());
end = PERFORMANCE_NOW();
TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TIMESTAMP0(
- "node.perf,node.perf.timerify", *name, *name, end / 1000);
+ TRACING_CATEGORY_NODE2(perf, timerify),
+ *name, *name, end / 1000);
if (ret.IsEmpty()) {
try_catch.ReThrow();
@@ -317,14 +322,16 @@ void TimerFunctionCall(const FunctionCallbackInfo<Value>& args) {
} else {
start = PERFORMANCE_NOW();
TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0(
- "node.perf,node.perf.timerify", *name, *name, start / 1000);
+ TRACING_CATEGORY_NODE2(perf, timerify),
+ *name, *name, start / 1000);
v8::MaybeLocal<Value> ret = fn->Call(context,
args.This(),
call_args.size(),
call_args.data());
end = PERFORMANCE_NOW();
TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TIMESTAMP0(
- "node.perf,node.perf.timerify", *name, *name, end / 1000);
+ TRACING_CATEGORY_NODE2(perf, timerify),
+ *name, *name, end / 1000);
if (ret.IsEmpty()) {
try_catch.ReThrow();