From 436d16387ab7ea21c6f05bcafae99fd09d534588 Mon Sep 17 00:00:00 2001 From: Etienne Pierre-doray Date: Fri, 22 Nov 2024 19:45:00 +0000 Subject: [PATCH] [chrome] Support flow on chrome trigger This will be used to connect to causal slice (e.g. histogram track event for histogram triggers) Change-Id: I05278cdf2d7186f02820004514720bd31dc448d1 --- protos/perfetto/trace/chrome/chrome_trigger.proto | 2 ++ protos/perfetto/trace/perfetto_trace.proto | 2 ++ src/trace_processor/importers/proto/metadata_module.cc | 8 +++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/protos/perfetto/trace/chrome/chrome_trigger.proto b/protos/perfetto/trace/chrome/chrome_trigger.proto index 4ba021af9f..0728c93ed1 100644 --- a/protos/perfetto/trace/chrome/chrome_trigger.proto +++ b/protos/perfetto/trace/chrome/chrome_trigger.proto @@ -25,4 +25,6 @@ message ChromeTrigger { optional string trigger_name = 1; // SHA1 hash of the trigger name. optional fixed32 trigger_name_hash = 2; + // Flow id which should terminate on this trigger. + optional fixed64 flow_id = 3; } diff --git a/protos/perfetto/trace/perfetto_trace.proto b/protos/perfetto/trace/perfetto_trace.proto index ddf7de8a78..52b5e84878 100644 --- a/protos/perfetto/trace/perfetto_trace.proto +++ b/protos/perfetto/trace/perfetto_trace.proto @@ -6352,6 +6352,8 @@ message ChromeTrigger { optional string trigger_name = 1; // SHA1 hash of the trigger name. optional fixed32 trigger_name_hash = 2; + // Flow id which should terminate on this trigger. + optional fixed64 flow_id = 3; } // End of protos/perfetto/trace/chrome/chrome_trigger.proto diff --git a/src/trace_processor/importers/proto/metadata_module.cc b/src/trace_processor/importers/proto/metadata_module.cc index 01024c5174..a979e83171 100644 --- a/src/trace_processor/importers/proto/metadata_module.cc +++ b/src/trace_processor/importers/proto/metadata_module.cc @@ -19,6 +19,7 @@ #include "perfetto/ext/base/base64.h" #include "perfetto/ext/base/string_utils.h" #include "perfetto/ext/base/uuid.h" +#include "src/trace_processor/importers/common/flow_tracker.h" #include "src/trace_processor/importers/common/metadata_tracker.h" #include "src/trace_processor/importers/common/slice_tracker.h" #include "src/trace_processor/importers/common/track_tracker.h" @@ -140,7 +141,7 @@ void MetadataModule::ParseChromeTrigger(int64_t ts, ConstBytes blob) { name_id = context_->storage->InternString(base::StringView("chrome_trigger")); } - context_->slice_tracker->Scoped( + auto slice_id = context_->slice_tracker->Scoped( ts, track_id, cat_id, name_id, /* duration = */ 0, [&](ArgsTracker::BoundInserter* inserter) { inserter->AddArg( @@ -150,6 +151,11 @@ void MetadataModule::ParseChromeTrigger(int64_t ts, ConstBytes blob) { inserter->AddArg(chrome_trigger_name_id_, Variadic::String(name_id)); } }); + if (slice_id && trigger.has_flow_id() && + context_->flow_tracker->IsActive(trigger.flow_id())) { + context_->flow_tracker->End(*slice_id, trigger.flow_id(), + /* close_flow = */ true); + } MetadataTracker* metadata = context_->metadata_tracker.get(); metadata->SetDynamicMetadata(