From 2509ae1806d3fcb6638165d3e2e9fe4cf1d91aa9 Mon Sep 17 00:00:00 2001 From: theanarkh Date: Tue, 1 Nov 2022 23:56:01 +0800 Subject: [PATCH] trace_events: add new categories --- src/inspector/tracing_agent.cc | 11 ++-- .../parallel/test-inspector-tracing-domain.js | 52 ++++++++++--------- 2 files changed, 34 insertions(+), 29 deletions(-) diff --git a/src/inspector/tracing_agent.cc b/src/inspector/tracing_agent.cc index caed5b044e86c9..f51bcc9423afeb 100644 --- a/src/inspector/tracing_agent.cc +++ b/src/inspector/tracing_agent.cc @@ -174,24 +174,27 @@ DispatchResponse TracingAgent::getCategories( std::unique_ptr>* categories) { *categories = Array::create(); protocol::Array* 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(); } diff --git a/test/parallel/test-inspector-tracing-domain.js b/test/parallel/test-inspector-tracing-domain.js index a1f9724dab677f..32179f1fa3a8a2 100644 --- a/test/parallel/test-inspector-tracing-domain.js +++ b/test/parallel/test-inspector-tracing-domain.js @@ -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) => { @@ -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 });