@@ -310,8 +310,9 @@ const uint64_t kNoId = 0;
310
310
311
311
class TraceEventHelper {
312
312
public:
313
- static v8::TracingController* GetTracingController ();
314
- static void SetTracingController (v8::TracingController* controller);
313
+ static TracingController* GetTracingController ();
314
+ static Agent* GetAgent ();
315
+ static void SetAgent (Agent* agent);
315
316
};
316
317
317
318
// TraceID encapsulates an ID that can either be an integer or pointer. Pointers
@@ -487,6 +488,26 @@ static V8_INLINE uint64_t AddTraceEventWithTimestampImpl(
487
488
arg_names, arg_types, arg_values, arg_convertables, flags, timestamp);
488
489
}
489
490
491
+ static V8_INLINE void AddMetadataEventImpl (
492
+ const uint8_t * category_group_enabled, const char * name, int32_t num_args,
493
+ const char ** arg_names, const uint8_t * arg_types,
494
+ const uint64_t * arg_values, unsigned int flags) {
495
+ std::unique_ptr<v8::ConvertableToTraceFormat> arg_convertibles[2 ];
496
+ if (num_args > 0 && arg_types[0 ] == TRACE_VALUE_TYPE_CONVERTABLE) {
497
+ arg_convertibles[0 ].reset (reinterpret_cast <v8::ConvertableToTraceFormat*>(
498
+ static_cast <intptr_t >(arg_values[0 ])));
499
+ }
500
+ if (num_args > 1 && arg_types[1 ] == TRACE_VALUE_TYPE_CONVERTABLE) {
501
+ arg_convertibles[1 ].reset (reinterpret_cast <v8::ConvertableToTraceFormat*>(
502
+ static_cast <intptr_t >(arg_values[1 ])));
503
+ }
504
+ node::tracing::TracingController* controller =
505
+ node::tracing::TraceEventHelper::GetTracingController ();
506
+ return controller->AddMetadataEvent (
507
+ category_group_enabled, name, num_args, arg_names, arg_types, arg_values,
508
+ arg_convertibles, flags);
509
+ }
510
+
490
511
// Define SetTraceValue for each allowed type. It stores the type and
491
512
// value in the return arguments. This allows this API to avoid declaring any
492
513
// structures so that it is portable to third_party libraries.
@@ -632,23 +653,16 @@ static V8_INLINE uint64_t AddTraceEventWithTimestamp(
632
653
}
633
654
634
655
template <class ARG1_TYPE >
635
- static V8_INLINE uint64_t AddMetadataEvent (
656
+ static V8_INLINE void AddMetadataEvent (
636
657
const uint8_t * category_group_enabled, const char * name,
637
658
const char * arg1_name, ARG1_TYPE&& arg1_val) {
638
659
const int num_args = 1 ;
639
660
uint8_t arg_type;
640
661
uint64_t arg_value;
641
662
SetTraceValue (std::forward<ARG1_TYPE>(arg1_val), &arg_type, &arg_value);
642
- // TODO(ofrobots): It would be good to add metadata events to a separate
643
- // buffer so that they can be periodically reemitted. For now, we have a
644
- // single buffer, so we just add them to the main buffer.
645
- return TRACE_EVENT_API_ADD_TRACE_EVENT (
646
- TRACE_EVENT_PHASE_METADATA,
647
- category_group_enabled, name,
648
- node::tracing::kGlobalScope , // scope
649
- node::tracing::kNoId , // id
650
- node::tracing::kNoId , // bind_id
651
- num_args, &arg1_name, &arg_type, &arg_value, TRACE_EVENT_FLAG_NONE);
663
+ AddMetadataEventImpl (
664
+ category_group_enabled, name, num_args, &arg1_name, &arg_type, &arg_value,
665
+ TRACE_EVENT_FLAG_NONE);
652
666
}
653
667
654
668
// Used by TRACE_EVENTx macros. Do not use directly.
0 commit comments