Skip to content

Commit

Permalink
trace_events: add new categories
Browse files Browse the repository at this point in the history
PR-URL: #45266
Refs: #45092
Refs: #44458
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
theanarkh authored and danielleadams committed Jan 3, 2023
1 parent 319ae09 commit 210cbcb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 30 deletions.
13 changes: 8 additions & 5 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();
// In alphabetical order
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.perf.usertiming");
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.timerify',
'node.perf.usertiming',
'node.promises.rejections',
'node.threadpoolwork.async',
'node.threadpoolwork.sync',
'node.vm.script',
'v8',
].sort();
assert.ok(categories.length === expectedCategories.length);
categories.forEach((category, index) => {
const value = expectedCategories[index];
assert.ok(category === value, `${category} is out of order, expect ${value}`);
});

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

0 comments on commit 210cbcb

Please sign in to comment.