Skip to content

Commit

Permalink
[chrome] Support flow on chrome trigger
Browse files Browse the repository at this point in the history
This will be used to connect to causal slice (e.g. histogram
track event for histogram triggers)

Change-Id: I05278cdf2d7186f02820004514720bd31dc448d1
Etienne Pierre-doray committed Nov 22, 2024
1 parent dc890fc commit 436d163
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions protos/perfetto/trace/chrome/chrome_trigger.proto
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 2 additions & 0 deletions protos/perfetto/trace/perfetto_trace.proto
Original file line number Diff line number Diff line change
@@ -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
8 changes: 7 additions & 1 deletion src/trace_processor/importers/proto/metadata_module.cc
Original file line number Diff line number Diff line change
@@ -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(

0 comments on commit 436d163

Please sign in to comment.