Skip to content

Commit

Permalink
trace_events: add new categories
Browse files Browse the repository at this point in the history
  • Loading branch information
theanarkh committed Nov 8, 2022
1 parent 1af63a9 commit 2509ae1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 29 deletions.
11 changes: 7 additions & 4 deletions src/inspector/tracing_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,24 +174,27 @@ DispatchResponse TracingAgent::getCategories(
std::unique_ptr<protocol::Array<String>>* categories) {
*categories = Array<String>::create();
protocol::Array<String>* categories_list = categories->get();
// Must match expectedCategories in test-inspector-tracing-domain.js.
categories_list->addItem("node");
categories_list->addItem("node.async_hooks");
categories_list->addItem("node.bootstrap");
categories_list->addItem("node.console");
categories_list->addItem("node.dns.native");
categories_list->addItem("node.net.native");
categories_list->addItem("node.environment");
categories_list->addItem("node.fs.sync");
categories_list->addItem("node.fs_dir.sync");
categories_list->addItem("node.fs.async");
categories_list->addItem("node.fs.sync");
categories_list->addItem("node.fs_dir.async");
categories_list->addItem("node.fs_dir.sync");
categories_list->addItem("node.http");
categories_list->addItem("node.net.native");
categories_list->addItem("node.perf");
categories_list->addItem("node.perf.usertiming");
categories_list->addItem("node.perf.timerify");
categories_list->addItem("node.promises.rejections");
categories_list->addItem("node.threadpoolwork.async");
categories_list->addItem("node.threadpoolwork.sync");
categories_list->addItem("node.vm.script");
categories_list->addItem("v8");
categories_list->addItem("node.http");
return DispatchResponse::OK();
}

Expand Down
52 changes: 27 additions & 25 deletions test/parallel/test-inspector-tracing-domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ const { Session } = require('inspector');

const session = new Session();

function compareIgnoringOrder(array1, array2) {
const set = new Set(array1);
const test = set.size === array2.length && array2.every((el) => set.has(el));
assert.ok(test, `[${array1}] differs from [${array2}]`);
}

function post(message, data) {
return new Promise((resolve, reject) => {
session.post(message, data, (err, result) => {
Expand Down Expand Up @@ -48,25 +42,33 @@ async function test() {
session.on('NodeTracing.dataCollected', (n) => traceNotification = n);
session.on('NodeTracing.tracingComplete', () => tracingComplete = true);
const { categories } = await post('NodeTracing.getCategories');
compareIgnoringOrder(['node',
'node.async_hooks',
'node.bootstrap',
'node.console',
'node.dns.native',
'node.net.native',
'node.environment',
'node.fs.sync',
'node.fs_dir.sync',
'node.fs.async',
'node.fs_dir.async',
'node.perf',
'node.perf.usertiming',
'node.perf.timerify',
'node.promises.rejections',
'node.vm.script',
'v8',
'node.http',
], categories);
const expectedCategories = [
'node',
'node.async_hooks',
'node.bootstrap',
'node.console',
'node.dns.native',
'node.environment',
'node.fs.async',
'node.fs.sync',
'node.fs_dir.async',
'node.fs_dir.sync',
'node.http',
'node.net.native',
'node.perf',
'node.perf.usertiming',
'node.perf.timerify',
'node.promises.rejections',
'node.threadpoolwork.async',
'node.threadpoolwork.sync',
'node.vm.script',
'v8'
];
assert.ok(categories.length === expectedCategories.length);
categories.forEach((category, index) => {
const value = expectedCategories[index];
assert.ok(category === value, `${category} differs from ${value}`);
});

const traceConfig = { includedCategories: ['v8'] };
await post('NodeTracing.start', { traceConfig });
Expand Down

0 comments on commit 2509ae1

Please sign in to comment.