diff options
author | Ali Ijaz Sheikh <ofrobots@google.com> | 2018-05-15 21:52:18 +0300 |
---|---|---|
committer | Ali Ijaz Sheikh <ofrobots@google.com> | 2018-05-18 20:42:35 +0300 |
commit | 3ff723f940c9b18f281131fad1d0c967c45169dd (patch) | |
tree | 65a93544c3db2d00227d2e8a0a5e8f471876087d /src/tracing | |
parent | 42a4a606457e01df51943c9c1e68ceaf9cafa0fe (diff) |
src: trace_events: support for metadata events
Add support for metadata events. At this point they are added to the
main buffer. Emit a metadata event for the main thread.
PR-URL: https://github.com/nodejs/node/pull/20757
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'src/tracing')
-rw-r--r-- | src/tracing/trace_event.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/tracing/trace_event.h b/src/tracing/trace_event.h index 3fbe1b0a1f9..1165fca59a9 100644 --- a/src/tracing/trace_event.h +++ b/src/tracing/trace_event.h @@ -118,6 +118,15 @@ enum CategoryGroupEnabledFlags { node::tracing::TraceEventHelper::GetTracingController() \ ->UpdateTraceEventDuration +// Adds a metadata event to the trace log. The |AppendValueAsTraceFormat| method +// on the convertable value will be called at flush time. +// TRACE_EVENT_API_ADD_METADATA_EVENT( +// const unsigned char* category_group_enabled, +// const char* event_name, +// const char* arg_name, +// std::unique_ptr<ConvertableToTraceFormat> arg_value) +#define TRACE_EVENT_API_ADD_METADATA_EVENT node::tracing::AddMetadataEvent + // Defines atomic operations used internally by the tracing system. #define TRACE_EVENT_API_ATOMIC_WORD intptr_t #define TRACE_EVENT_API_ATOMIC_LOAD(var) (var) @@ -259,6 +268,16 @@ enum CategoryGroupEnabledFlags { } \ } while (0) +#define INTERNAL_TRACE_EVENT_METADATA_ADD(category_group, name, ...) \ + do { \ + INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ + if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ + TRACE_EVENT_API_ADD_METADATA_EVENT( \ + INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ + ##__VA_ARGS__); \ + } \ + } while(0) + // Enter and leave a context based on the current scope. #define INTERNAL_TRACE_EVENT_SCOPED_CONTEXT(category_group, name, context) \ struct INTERNAL_TRACE_EVENT_UID(ScopedContext) { \ @@ -612,6 +631,26 @@ static V8_INLINE uint64_t AddTraceEventWithTimestamp( arg_names, arg_types, arg_values, flags, timestamp); } +template <class ARG1_TYPE> +static V8_INLINE uint64_t AddMetadataEvent( + const uint8_t* category_group_enabled, const char* name, + const char* arg1_name, ARG1_TYPE&& arg1_val) { + const int num_args = 1; + uint8_t arg_type; + uint64_t arg_value; + SetTraceValue(std::forward<ARG1_TYPE>(arg1_val), &arg_type, &arg_value); + // TODO(ofrobots): It would be good to add metadata events to a separate + // buffer so that they can be periodically reemitted. For now, we have a + // single buffer, so we just add them to the main buffer. + return TRACE_EVENT_API_ADD_TRACE_EVENT( + TRACE_EVENT_PHASE_METADATA, + category_group_enabled, name, + node::tracing::kGlobalScope, // scope + node::tracing::kNoId, // id + node::tracing::kNoId, // bind_id + num_args, &arg1_name, &arg_type, &arg_value, TRACE_EVENT_FLAG_NONE); +} + // Used by TRACE_EVENTx macros. Do not use directly. class ScopedTracer { public: |