Add chrome metadata field in trace packet
This will serve as a strongly typed version of the the Chrome bundle's
metadata proto.
Bug: 133252157
Change-Id: I6852d5bdaeb46a4b73d6041e85b2faff8624a3d4
diff --git a/protos/BUILD b/protos/BUILD
index 647c051..36bd760 100644
--- a/protos/BUILD
+++ b/protos/BUILD
@@ -469,6 +469,7 @@
name = "trace_chrome",
srcs = [
"perfetto/trace/chrome/chrome_benchmark_metadata.proto",
+ "perfetto/trace/chrome/chrome_metadata.proto",
"perfetto/trace/chrome/chrome_trace_event.proto",
],
has_services = 1,
@@ -506,6 +507,7 @@
name = "trace_chrome_zero",
srcs = [
"perfetto/trace/chrome/chrome_benchmark_metadata.proto",
+ "perfetto/trace/chrome/chrome_metadata.proto",
"perfetto/trace/chrome/chrome_trace_event.proto",
],
deps = [
diff --git a/protos/perfetto/trace/chrome/BUILD.gn b/protos/perfetto/trace/chrome/BUILD.gn
index 3277787..18ccfe2 100644
--- a/protos/perfetto/trace/chrome/BUILD.gn
+++ b/protos/perfetto/trace/chrome/BUILD.gn
@@ -18,6 +18,7 @@
chrome_proto_names = [
"chrome_trace_event.proto",
"chrome_benchmark_metadata.proto",
+ "chrome_metadata.proto",
]
minimal_chrome_proto_names = [ "chrome_trace_packet.proto" ]
diff --git a/protos/perfetto/trace/chrome/chrome_metadata.proto b/protos/perfetto/trace/chrome/chrome_metadata.proto
new file mode 100644
index 0000000..22c5f2d
--- /dev/null
+++ b/protos/perfetto/trace/chrome/chrome_metadata.proto
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+option optimize_for = LITE_RUNTIME;
+
+package perfetto.protos;
+
+// Metadata for chrome traces.
+message ChromeMetadataPacket {
+ optional BackgroundTracingMetadata background_tracing_metadata = 1;
+}
+
+// Metadata related to background tracing scenarios, states and triggers.
+message BackgroundTracingMetadata {
+ // Information about a trigger rule defined in the experiment config.
+ message TriggerRule {
+ enum TriggerType {
+ TRIGGER_UNSPECIFIED = 0;
+
+ // Traces are triggered by specific range of values of an UMA histogram.
+ MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE = 1;
+
+ // Traces are triggered by specific named events in chromium codebase,
+ // like "second-update-failure".
+ MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED = 2;
+ }
+ optional TriggerType trigger_type = 1;
+
+ // Configuration of histogram trigger.
+ message HistogramRule {
+ // UMA histogram name hash, same as HistogramEventProto.name_hash.
+ optional fixed64 histogram_name_hash = 1;
+
+ // Range of values of the histogram that activates trigger.
+ optional int64 histogram_min_trigger = 2;
+ optional int64 histogram_max_trigger = 3;
+ }
+ optional HistogramRule histogram_rule = 2;
+
+ // Configuration of named trigger.
+ message NamedRule {
+ enum EventType {
+ UNSPECIFIED = 0;
+ SESSION_RESTORE = 1;
+ NAVIGATION = 2;
+ STARTUP = 3;
+
+ TEST_RULE = 1000;
+ }
+ optional EventType event_type = 1;
+ }
+ optional NamedRule named_rule = 3;
+ }
+
+ // Specifies the rule that caused the trace to be uploaded.
+ optional TriggerRule triggered_rule = 1;
+
+ // List of all active triggers in current session, when trace was triggered.
+ repeated TriggerRule active_rules = 2;
+}
diff --git a/protos/perfetto/trace/perfetto_trace.proto b/protos/perfetto/trace/perfetto_trace.proto
index d4e6cc9..b448fb0 100644
--- a/protos/perfetto/trace/perfetto_trace.proto
+++ b/protos/perfetto/trace/perfetto_trace.proto
@@ -434,6 +434,64 @@
// End of protos/perfetto/trace/chrome/chrome_benchmark_metadata.proto
+// Begin of protos/perfetto/trace/chrome/chrome_metadata.proto
+
+// Metadata for chrome traces.
+message ChromeMetadataPacket {
+ optional BackgroundTracingMetadata background_tracing_metadata = 1;
+}
+
+// Metadata related to background tracing scenarios, states and triggers.
+message BackgroundTracingMetadata {
+ // Information about a trigger rule defined in the experiment config.
+ message TriggerRule {
+ enum TriggerType {
+ TRIGGER_UNSPECIFIED = 0;
+
+ // Traces are triggered by specific range of values of an UMA histogram.
+ MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE = 1;
+
+ // Traces are triggered by specific named events in chromium codebase,
+ // like "second-update-failure".
+ MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED = 2;
+ }
+ optional TriggerType trigger_type = 1;
+
+ // Configuration of histogram trigger.
+ message HistogramRule {
+ // UMA histogram name hash, same as HistogramEventProto.name_hash.
+ optional fixed64 histogram_name_hash = 1;
+
+ // Range of values of the histogram that activates trigger.
+ optional int64 histogram_min_trigger = 2;
+ optional int64 histogram_max_trigger = 3;
+ }
+ optional HistogramRule histogram_rule = 2;
+
+ // Configuration of named trigger.
+ message NamedRule {
+ enum EventType {
+ UNSPECIFIED = 0;
+ SESSION_RESTORE = 1;
+ NAVIGATION = 2;
+ STARTUP = 3;
+
+ TEST_RULE = 1000;
+ }
+ optional EventType event_type = 1;
+ }
+ optional NamedRule named_rule = 3;
+ }
+
+ // Specifies the rule that caused the trace to be uploaded.
+ optional TriggerRule triggered_rule = 1;
+
+ // List of all active triggers in current session, when trace was triggered.
+ repeated TriggerRule active_rules = 2;
+}
+
+// End of protos/perfetto/trace/chrome/chrome_metadata.proto
+
// Begin of protos/perfetto/trace/clock_snapshot.proto
// A snapshot of clock readings to allow for trace alignment.
@@ -2954,7 +3012,7 @@
// TracePacket(s).
//
// Next reserved id: 13 (up to 15).
-// Next id: 51.
+// Next id: 52.
message TracePacket {
// TODO(primiano): in future we should add a timestamp_clock_domain field to
// allow mixing timestamps from different clock domains.
@@ -2985,6 +3043,7 @@
PackagesList packages_list = 47;
ChromeBenchmarkMetadata chrome_benchmark_metadata = 48;
PerfettoMetatrace perfetto_metatrace = 49;
+ ChromeMetadataPacket chrome_metadata = 51;
// Only used by TrackEvent.
ProcessDescriptor process_descriptor = 43;
diff --git a/protos/perfetto/trace/trace_packet.proto b/protos/perfetto/trace/trace_packet.proto
index e355eb0..1bf5bd7 100644
--- a/protos/perfetto/trace/trace_packet.proto
+++ b/protos/perfetto/trace/trace_packet.proto
@@ -22,6 +22,7 @@
import "perfetto/trace/android/android_log.proto";
import "perfetto/trace/android/packages_list.proto";
import "perfetto/trace/chrome/chrome_benchmark_metadata.proto";
+import "perfetto/trace/chrome/chrome_metadata.proto";
import "perfetto/trace/chrome/chrome_trace_event.proto";
import "perfetto/trace/clock_snapshot.proto";
import "perfetto/trace/filesystem/inode_file_map.proto";
@@ -48,7 +49,7 @@
// TracePacket(s).
//
// Next reserved id: 13 (up to 15).
-// Next id: 51.
+// Next id: 52.
message TracePacket {
// TODO(primiano): in future we should add a timestamp_clock_domain field to
// allow mixing timestamps from different clock domains.
@@ -79,6 +80,7 @@
PackagesList packages_list = 47;
ChromeBenchmarkMetadata chrome_benchmark_metadata = 48;
PerfettoMetatrace perfetto_metatrace = 49;
+ ChromeMetadataPacket chrome_metadata = 51;
// Only used by TrackEvent.
ProcessDescriptor process_descriptor = 43;