• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2019 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5syntax = "proto2";
6
7option optimize_for = LITE_RUNTIME;
8option java_package = "org.chromium.components.metrics";
9
10package metrics;
11
12// One structured metrics event, containing several hashed and unhashed metrics
13// related to a single event type. Structured metrics have hashing keys based on
14// the project. A project refers to a use-case of the framework (ie bluetooth,
15// event sequence).
16//
17// Structured metrics is currently only used for the CrOS platform, so some of
18// the fields are CrOS-specific (ie device_project_id, user_project_id). If
19// structured metrics were to expand to other platforms, these fields will need
20// to be revisited.
21//
22// Next tag: 10
23message StructuredEventProto {
24  // A per-client, per-profile, per-project ID that is used only for structured
25  // metrics. For projects recorded from Chrome OS's platform2 repository, this
26  // ID is device-wide, not per-profile. The ID is rotated at least every 90
27  // days.
28  //
29  // For events of type SEQUENCE, the ID will be rotated every 120 days.
30  optional fixed64 profile_event_id = 1;
31
32  // A per-profile, per-project ID used only for events of type SEQUENCE. A
33  // device may have multiple profiles and multiple projects (ie cros-events).
34  //
35  // This ID is generated by applying HMAC on a locally-generated GUID (which is
36  // never sent) with a per-profile, per-project key. The first 8 bytes of the
37  // resulting string will be emitted.
38  //
39  // For events recorded when a user is not logged in or for events recorded
40  // outside of Chrome, this field should be empty.
41  //
42  // Since the per-profile, per-project keys are rotated every 120 days, this
43  // means that the |user_project_id| will also change every N days. For more
44  // details on how keys are rotated, refer to go/structured-metrics.
45  optional fixed64 user_project_id = 7;
46
47  // A device-wide, per-project ID used only for events of type SEQUENCE. This
48  // ID is rotated every 120 days.
49  //
50  // This ID is generated by hashing a locally-generated GUID (which is never
51  // sent) with a per-device, per-project key. The first 8 bytes of thee
52  // resulting string will be emitted.
53  //
54  // Since the per-device, per-project keys are rotated every N (default 90)
55  // days, this means that the |device_project_id| will also change every N
56  // days. For more details on how keys are rotated, refer to
57  // go/structured-metrics.
58  //
59  // Note that an event may have both a |device_project_id| and
60  // |user_project_id|.
61  optional fixed64 device_project_id = 8;
62
63  // The first 8 bytes of the MD5 hash of the event's name as a string. Each
64  // name is defined in src/tools/metrics/structured/structured.xml, and this
65  // will be the hash of one of those.
66  optional fixed64 event_name_hash = 2;
67
68  // All metric values for this event. Each metric has two properties defined in
69  // structured.xml that determine what is recorded.
70  //
71  // 1. Metric name. This is a string, and the first 8 bytes of its MD5 hash is
72  //    recorded as name_hash.
73  //
74  // 2. Kind. Each metric can store four kinds of values.
75  //
76  //    - int64. The client supplies an int64 value for the metric, and that
77  //      value is recorded as-is in value_int64.
78  //
79  //    - string. The client supplies a string value for the metric, which is
80  //      recorded as-is in value_string. This is sometimes referred to as a
81  //      "raw string" to differentiate from the following.
82  //
83  //    - hashed-string. The client supplies an arbitrary string for the metric.
84  //      The string itself is not recorded, instead, value_hmac records the
85  //      first 8 bytes of:
86  //
87  //          HMAC_SHA256(concat(string, metric_name), event_key)
88  //
89  //    - double. The client supplies a double value for the metric, which is
90  //      recorded as-is in value_double.
91  //
92  //      The event_key is a per-profile, per-client, per-project secret 32-byte
93  //      key used only for signing hashed values for this event. Keys should
94  //      never leave the device, and are rotated at least every 90 days.
95  //
96  //    - int64 array: This client supplies an array of int64 values for the
97  //      metric. Each metric will have an max defined by the metric definition.
98  message Metric {
99    optional fixed64 name_hash = 1;
100
101    // Wrapper of repeated integer fields.
102    message RepeatedInt64 {
103      repeated int64 values = 1 [packed = true];
104    }
105
106    oneof value {
107      fixed64 value_hmac = 2;
108      int64 value_int64 = 3;
109      string value_string = 4;
110      double value_double = 5;
111      RepeatedInt64 value_repeated_int64 = 6;
112    }
113  }
114
115  repeated Metric metrics = 3;
116
117  // Type of this event, which determines which log source the event is saved
118  // into. An event should have type RAW_STRING if and only if the event may
119  // contain raw string metrics, ie. strings that have not been HMAC'd. The
120  // UNKNOWN value is considered an error and should never be sent.
121  //
122  // An event should be marked as a SEQUENCE if it contains temporal data.
123  enum EventType {
124    UNKNOWN = 0;
125    REGULAR = 1;
126    RAW_STRING = 2;
127    SEQUENCE = 3;
128  }
129
130  optional EventType event_type = 4;
131
132  // The project name hash is the first 8 bytes of the MD5 hash of the project
133  // name that is defined in src/tools/metrics/structured/structured.xml.
134  optional fixed64 project_name_hash = 5;
135
136  // These enum values represent the type of user segment for the primary
137  // user.
138  enum PrimaryUserSegment {
139    UNKNOWN_PRIMARY_USER_TYPE = 0;
140
141    // Primary profile is for an unmanaged user.
142    UNMANAGED = 1;
143
144    // Primary profile is for a user belonging to a K-12 EDU organization.
145    K12 = 2;
146
147    // Primary profile is for a user belonging to an university EDU
148    // organization.
149    UNIVERSITY = 3;
150
151    // Primary profile is for a user belonging to a non-profit organization.
152    NON_PROFIT = 4;
153
154    // Primary profile is for a user belonging to an enterprise organization.
155    ENTERPRISE_ORGANIZATION = 5;
156
157    // Primary profile is for a kiosk app.
158    KIOS_APP = 6;
159
160    // Primary profile is for a managed guest session.
161    MANAGED_GUEST_SESSION = 7;
162
163    // Primary profile is for a Demo Mode.
164    DEMO_MODE = 8;
165  }
166
167  // Metadata associated with events for which relative order in which the
168  // events occur are of interest.
169  //
170  // Next tag: 6
171  message EventSequenceMetadata {
172    // GUIDs generated on the client to uniquely identify an event. These event
173    // IDs will be used to establish relationships between events on the client.
174    optional fixed64 event_unique_id = 1;
175
176    // Time elapsed since boot time. Note that system uptime includes duration a
177    // device has spent asleep. System uptime resets when a machine reboots.
178    // Granularity is in milliseconds.
179    optional int64 system_uptime = 2;
180
181    // Monotonically increasing number incremented every time a system reset is
182    // detected. This value will be reset to 0 in the event of a powerwash.
183    optional int64 reset_counter = 3;
184
185    // The number of weeks since the client id rotated.
186    optional uint32 client_id_rotation_weeks = 4;
187
188    // The segment policy of the user.
189    optional PrimaryUserSegment primary_user_segment = 5;
190  }
191
192  // Metadata associated with event type SEQUENCE. This field will be stripped
193  // if the event is not of type SEQUENCE.
194  optional EventSequenceMetadata event_sequence_metadata = 6;
195}
196
197// The top-level proto for structured metrics. One StructuredDataProto is
198// uploaded per UMA upload containing structured metrics. Contains all
199// structured events for that upload, and any other metadata.
200//
201// Next tag: 4
202message StructuredDataProto {
203  repeated StructuredEventProto events = 1;
204
205  // Whether the device is enrolled and may be controlled by a policy.
206  // Deprecated as of Chrome M119, use |device_segment| to determine if the
207  // device is enrolled.
208  optional bool is_device_enrolled = 2 [deprecated = true];
209
210  // The broader market segment the device is used.
211  enum DeviceSegment {
212    UNKNOWN = 0;
213    CONSUMER = 1;
214    EDUCATION = 2;
215    ENTERPRISE = 3;
216  }
217
218  // The segment policy of the device.
219  optional DeviceSegment device_segment = 3;
220}
221