diff --git a/src/async_wrap.cc b/src/async_wrap.cc index 7b7930187bd5..2009970ce284 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -110,8 +110,7 @@ void AsyncWrap::EmitPromiseResolve(Environment* env, double async_id) { } void AsyncWrap::EmitTraceAsyncStart() const { - if (*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( - TRACING_CATEGORY_NODE1(async_hooks))) { + if (TRACE_EVENT_CATEGORY_ENABLED(TRACING_CATEGORY_NODE1(async_hooks))) { tracing::AsyncWrapArgs data(env()->execution_async_id(), get_trigger_async_id()); TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(TRACING_CATEGORY_NODE1(async_hooks), diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 989ce5d6750c..ed76490bf282 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -1014,8 +1014,7 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { ContextifyScript* contextify_script = New(env, args.This()); - if (*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( - TRACING_CATEGORY_NODE2(vm, script)) != 0) { + if (TRACE_EVENT_CATEGORY_ENABLED(TRACING_CATEGORY_NODE2(vm, script))) { Utf8Value fn(isolate, filename); TRACE_EVENT_BEGIN1(TRACING_CATEGORY_NODE2(vm, script), "ContextifyScript::New", diff --git a/src/node_dir.cc b/src/node_dir.cc index ca7fc340bcdb..957444eea331 100644 --- a/src/node_dir.cc +++ b/src/node_dir.cc @@ -61,8 +61,7 @@ static const char* get_dir_func_name_by_type(uv_fs_type req_type) { #define TRACE_NAME(name) "fs_dir.sync." #name #define GET_TRACE_ENABLED \ - (*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( \ - TRACING_CATEGORY_NODE2(fs_dir, sync)) != 0) + TRACE_EVENT_CATEGORY_ENABLED(TRACING_CATEGORY_NODE2(fs_dir, sync)) #define FS_DIR_SYNC_TRACE(syscall) \ if (GET_TRACE_ENABLED) { \ TRACE_EVENT0(TRACING_CATEGORY_NODE2(fs_dir, sync), TRACE_NAME(syscall)); \ diff --git a/src/node_file.cc b/src/node_file.cc index b96771217b83..739acb850151 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -153,8 +153,7 @@ static const char* get_fs_func_name_by_type(uv_fs_type req_type) { #define TRACE_NAME(name) "fs.sync." #name #define GET_TRACE_ENABLED \ - (*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( \ - TRACING_CATEGORY_NODE2(fs, sync)) != 0) + TRACE_EVENT_CATEGORY_ENABLED(TRACING_CATEGORY_NODE2(fs, sync)) #define FS_SYNC_TRACE_BEGIN(syscall, ...) \ if (GET_TRACE_ENABLED) \ TRACE_EVENT_BEGIN( \ diff --git a/src/tracing/trace_event_legacy.h b/src/tracing/trace_event_legacy.h index 92b2e88d4823..9dc218ec6711 100644 --- a/src/tracing/trace_event_legacy.h +++ b/src/tracing/trace_event_legacy.h @@ -1012,6 +1012,14 @@ } \ } while (0) +// Expression form of the above, matching Perfetto's macro of the same name. +#define TRACE_EVENT_CATEGORY_ENABLED(category_group) \ + ([] { \ + bool enabled; \ + TRACE_EVENT_CATEGORY_GROUP_ENABLED(category_group, &enabled); \ + return enabled; \ + }()) + // Macro to explicitly warm up a given category group. This could be useful in // cases where we want to initialize a category group before any trace events // for that category group is reported. For example, to have a category group