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 c819010d13..b6e476bd08 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(