summaryrefslogtreecommitdiff
path: root/lib/internal/trace_events_async_hooks.js
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2018-03-05 14:46:19 -0800
committerJames M Snell <jasnell@gmail.com>2018-03-09 08:09:41 -0800
commit1dd9c9787bcf08db022ee63ce633fc9d497720e6 (patch)
treea10c638dfd43b2ef784cc8431ecd68a58c3aeb1e /lib/internal/trace_events_async_hooks.js
parent45277e23d5488dc11d705b850d310b4afb5085bb (diff)
downloadandroid-node-v8-1dd9c9787bcf08db022ee63ce633fc9d497720e6.tar.gz
android-node-v8-1dd9c9787bcf08db022ee63ce633fc9d497720e6.tar.bz2
android-node-v8-1dd9c9787bcf08db022ee63ce633fc9d497720e6.zip
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 'lib/internal/trace_events_async_hooks.js')
-rw-r--r--lib/internal/trace_events_async_hooks.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/internal/trace_events_async_hooks.js b/lib/internal/trace_events_async_hooks.js
index 704da98e14..db38fe99ad 100644
--- a/lib/internal/trace_events_async_hooks.js
+++ b/lib/internal/trace_events_async_hooks.js
@@ -15,6 +15,8 @@ const END_EVENT = 'e'.charCodeAt(0);
// non-init events, use a map to manually map the asyncId to the type name.
const typeMemory = new Map();
+const trace_event_category = 'node,node.async_hooks';
+
// It is faster to emit trace_events directly from C++. Thus, this happens in
// async_wrap.cc. However, events emitted from the JavaScript API or the
// Embedder C++ API can't be emitted from async_wrap.cc. Thus they are
@@ -27,7 +29,7 @@ const hook = async_hooks.createHook({
if (nativeProviders.has(type)) return;
typeMemory.set(asyncId, type);
- trace_events.emit(BEFORE_EVENT, 'node.async_hooks',
+ trace_events.emit(BEFORE_EVENT, trace_event_category,
type, asyncId,
'triggerAsyncId', triggerAsyncId,
'executionAsyncId', async_hooks.executionAsyncId());
@@ -37,7 +39,7 @@ const hook = async_hooks.createHook({
const type = typeMemory.get(asyncId);
if (type === undefined) return;
- trace_events.emit(BEFORE_EVENT, 'node.async_hooks',
+ trace_events.emit(BEFORE_EVENT, trace_event_category,
type + '_CALLBACK', asyncId);
},
@@ -45,7 +47,7 @@ const hook = async_hooks.createHook({
const type = typeMemory.get(asyncId);
if (type === undefined) return;
- trace_events.emit(END_EVENT, 'node.async_hooks',
+ trace_events.emit(END_EVENT, trace_event_category,
type + '_CALLBACK', asyncId);
},
@@ -53,7 +55,7 @@ const hook = async_hooks.createHook({
const type = typeMemory.get(asyncId);
if (type === undefined) return;
- trace_events.emit(END_EVENT, 'node.async_hooks',
+ trace_events.emit(END_EVENT, trace_event_category,
type, asyncId);
// cleanup asyncId to type map
@@ -63,7 +65,7 @@ const hook = async_hooks.createHook({
exports.setup = function() {
- if (trace_events.categoryGroupEnabled('node.async_hooks')) {
+ if (trace_events.categoryGroupEnabled(trace_event_category)) {
hook.enable();
}
};