Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trace_events: add new categories #45266

Merged
merged 1 commit into from Nov 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/inspector/tracing_agent.cc
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
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