1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17syntax = "proto2";
18
19package android.os.statsd;
20
21option java_package = "com.android.os";
22option java_outer_classname = "StatsLog";
23
24import "frameworks/base/cmds/statsd/src/atoms.proto";
25
26message DimensionsValue {
27  optional int32 field = 1;
28
29  oneof value {
30    string value_str = 2;
31    int32 value_int = 3;
32    int64 value_long = 4;
33    bool value_bool = 5;
34    float value_float = 6;
35    DimensionsValueTuple value_tuple = 7;
36    uint64 value_str_hash = 8;
37  }
38}
39
40message DimensionsValueTuple {
41  repeated DimensionsValue dimensions_value = 1;
42}
43
44message EventMetricData {
45  optional int64 elapsed_timestamp_nanos = 1;
46
47  optional Atom atom = 2;
48
49  optional int64 wall_clock_timestamp_nanos = 3;
50}
51
52message CountBucketInfo {
53  optional int64 start_bucket_elapsed_nanos = 1;
54
55  optional int64 end_bucket_elapsed_nanos = 2;
56
57  optional int64 count = 3;
58
59  optional int64 bucket_num = 4;
60
61  optional int64 start_bucket_elapsed_millis = 5;
62
63  optional int64 end_bucket_elapsed_millis = 6;
64}
65
66message CountMetricData {
67  optional DimensionsValue dimensions_in_what = 1;
68
69  optional DimensionsValue dimensions_in_condition = 2;
70
71  repeated CountBucketInfo bucket_info = 3;
72
73  repeated DimensionsValue dimension_leaf_values_in_what = 4;
74
75  repeated DimensionsValue dimension_leaf_values_in_condition = 5;
76}
77
78message DurationBucketInfo {
79  optional int64 start_bucket_elapsed_nanos = 1;
80
81  optional int64 end_bucket_elapsed_nanos = 2;
82
83  optional int64 duration_nanos = 3;
84
85  optional int64 bucket_num = 4;
86
87  optional int64 start_bucket_elapsed_millis = 5;
88
89  optional int64 end_bucket_elapsed_millis = 6;
90}
91
92message DurationMetricData {
93  optional DimensionsValue dimensions_in_what = 1;
94
95  optional DimensionsValue dimensions_in_condition = 2;
96
97  repeated DurationBucketInfo bucket_info = 3;
98
99  repeated DimensionsValue dimension_leaf_values_in_what = 4;
100
101  repeated DimensionsValue dimension_leaf_values_in_condition = 5;
102}
103
104message ValueBucketInfo {
105  optional int64 start_bucket_elapsed_nanos = 1;
106
107  optional int64 end_bucket_elapsed_nanos = 2;
108
109  optional int64 value = 3;
110
111  optional int64 bucket_num = 4;
112
113  optional int64 start_bucket_elapsed_millis = 5;
114
115  optional int64 end_bucket_elapsed_millis = 6;
116}
117
118message ValueMetricData {
119  optional DimensionsValue dimensions_in_what = 1;
120
121  optional DimensionsValue dimensions_in_condition = 2;
122
123  repeated ValueBucketInfo bucket_info = 3;
124
125  repeated DimensionsValue dimension_leaf_values_in_what = 4;
126
127  repeated DimensionsValue dimension_leaf_values_in_condition = 5;
128}
129
130message GaugeBucketInfo {
131  optional int64 start_bucket_elapsed_nanos = 1;
132
133  optional int64 end_bucket_elapsed_nanos = 2;
134
135  repeated Atom atom = 3;
136
137  repeated int64 elapsed_timestamp_nanos = 4;
138
139  repeated int64 wall_clock_timestamp_nanos = 5;
140
141  optional int64 bucket_num = 6;
142
143  optional int64 start_bucket_elapsed_millis = 7;
144
145  optional int64 end_bucket_elapsed_millis = 8;
146}
147
148message GaugeMetricData {
149  optional DimensionsValue dimensions_in_what = 1;
150
151  optional DimensionsValue dimensions_in_condition = 2;
152
153  repeated GaugeBucketInfo bucket_info = 3;
154
155  repeated DimensionsValue dimension_leaf_values_in_what = 4;
156
157  repeated DimensionsValue dimension_leaf_values_in_condition = 5;
158}
159
160message StatsLogReport {
161  optional int64 metric_id = 1;
162
163  // Fields 2 and 3 are reserved.
164
165  message SkippedBuckets {
166      optional int64 start_bucket_elapsed_nanos = 1;
167      optional int64 end_bucket_elapsed_nanos = 2;
168      optional int64 start_bucket_elapsed_millis = 3;
169      optional int64 end_bucket_elapsed_millis = 4;
170  }
171
172  message EventMetricDataWrapper {
173    repeated EventMetricData data = 1;
174  }
175  message CountMetricDataWrapper {
176    repeated CountMetricData data = 1;
177  }
178  message DurationMetricDataWrapper {
179    repeated DurationMetricData data = 1;
180  }
181  message ValueMetricDataWrapper {
182    repeated ValueMetricData data = 1;
183    repeated SkippedBuckets skipped = 2;
184  }
185
186  message GaugeMetricDataWrapper {
187    repeated GaugeMetricData data = 1;
188    repeated SkippedBuckets skipped = 2;
189  }
190
191  oneof data {
192    EventMetricDataWrapper event_metrics = 4;
193    CountMetricDataWrapper count_metrics = 5;
194    DurationMetricDataWrapper duration_metrics = 6;
195    ValueMetricDataWrapper value_metrics = 7;
196    GaugeMetricDataWrapper gauge_metrics = 8;
197  }
198
199  optional int64 time_base_elapsed_nano_seconds = 9;
200
201  optional int64 bucket_size_nano_seconds = 10;
202
203  optional DimensionsValue dimensions_path_in_what = 11;
204
205  optional DimensionsValue dimensions_path_in_condition = 12;
206}
207
208message UidMapping {
209    message PackageInfoSnapshot {
210        message PackageInfo {
211            optional string name = 1;
212
213            optional int64 version = 2;
214
215            optional int32 uid = 3;
216
217            optional bool deleted = 4;
218
219            optional uint64 name_hash = 5;
220        }
221        optional int64 elapsed_timestamp_nanos = 1;
222
223        repeated PackageInfo package_info = 2;
224    }
225    repeated PackageInfoSnapshot snapshots = 1;
226
227    message Change {
228        optional bool deletion = 1;
229
230        optional int64 elapsed_timestamp_nanos = 2;
231        optional string app = 3;
232        optional int32 uid = 4;
233
234        optional int64 new_version = 5;
235        optional int64 prev_version = 6;
236        optional uint64 app_hash = 7;
237    }
238    repeated Change changes = 2;
239}
240
241message ConfigMetricsReport {
242  repeated StatsLogReport metrics = 1;
243
244  optional UidMapping uid_map = 2;
245
246  optional int64 last_report_elapsed_nanos = 3;
247
248  optional int64 current_report_elapsed_nanos = 4;
249
250  optional int64 last_report_wall_clock_nanos = 5;
251
252  optional int64 current_report_wall_clock_nanos = 6;
253
254  message Annotation {
255      optional int64 field_int64 = 1;
256      optional int32 field_int32 = 2;
257  }
258  repeated Annotation annotation = 7;
259
260  enum DumpReportReason {
261      DEVICE_SHUTDOWN = 1;
262      CONFIG_UPDATED = 2;
263      CONFIG_REMOVED = 3;
264      GET_DATA_CALLED = 4;
265      ADB_DUMP = 5;
266      CONFIG_RESET = 6;
267      STATSCOMPANION_DIED = 7;
268  }
269  optional DumpReportReason dump_report_reason = 8;
270
271  repeated string strings = 9;
272}
273
274message ConfigMetricsReportList {
275  message ConfigKey {
276    optional int32 uid = 1;
277    optional int64 id = 2;
278  }
279  optional ConfigKey config_key = 1;
280
281  repeated ConfigMetricsReport reports = 2;
282
283  reserved 10;
284}
285
286message StatsdStatsReport {
287    optional int32 stats_begin_time_sec = 1;
288
289    optional int32 stats_end_time_sec = 2;
290
291    message MatcherStats {
292        optional int64 id = 1;
293        optional int32 matched_times = 2;
294    }
295
296    message ConditionStats {
297        optional int64 id = 1;
298        optional int32 max_tuple_counts = 2;
299    }
300
301    message MetricStats {
302        optional int64 id = 1;
303        optional int32 max_tuple_counts = 2;
304    }
305
306    message AlertStats {
307        optional int64 id = 1;
308        optional int32 alerted_times = 2;
309    }
310
311    message ConfigStats {
312        optional int32 uid = 1;
313        optional int64 id = 2;
314        optional int32 creation_time_sec = 3;
315        optional int32 deletion_time_sec = 4;
316        optional int32 reset_time_sec = 19;
317        optional int32 metric_count = 5;
318        optional int32 condition_count = 6;
319        optional int32 matcher_count = 7;
320        optional int32 alert_count = 8;
321        optional bool is_valid = 9;
322        repeated int32 broadcast_sent_time_sec = 10;
323        repeated int32 data_drop_time_sec = 11;
324        repeated int32 dump_report_time_sec = 12;
325        repeated int32 dump_report_data_size = 20;
326        repeated MatcherStats matcher_stats = 13;
327        repeated ConditionStats condition_stats = 14;
328        repeated MetricStats metric_stats = 15;
329        repeated AlertStats alert_stats = 16;
330        repeated MetricStats metric_dimension_in_condition_stats = 17;
331        message Annotation {
332            optional int64 field_int64 = 1;
333            optional int32 field_int32 = 2;
334        }
335        repeated Annotation annotation = 18;
336    }
337
338    repeated ConfigStats config_stats = 3;
339
340    message AtomStats {
341        optional int32 tag = 1;
342        optional int32 count = 2;
343    }
344
345    repeated AtomStats atom_stats = 7;
346
347    message UidMapStats {
348        optional int32 changes = 1;
349        optional int32 bytes_used = 2;
350        optional int32 dropped_changes = 3;
351        optional int32 deleted_apps = 4;
352    }
353    optional UidMapStats uidmap_stats = 8;
354
355    message AnomalyAlarmStats {
356        optional int32 alarms_registered = 1;
357    }
358    optional AnomalyAlarmStats anomaly_alarm_stats = 9;
359
360    message PulledAtomStats {
361        optional int32 atom_id = 1;
362        optional int64 total_pull = 2;
363        optional int64 total_pull_from_cache = 3;
364        optional int64 min_pull_interval_sec = 4;
365    }
366    repeated PulledAtomStats pulled_atom_stats = 10;
367
368    message LoggerErrorStats {
369        optional int32 logger_disconnection_sec = 1;
370        optional int32 error_code = 2;
371    }
372    repeated LoggerErrorStats logger_error_stats = 11;
373
374    message PeriodicAlarmStats {
375        optional int32 alarms_registered = 1;
376    }
377    optional PeriodicAlarmStats periodic_alarm_stats = 12;
378
379    message  SkippedLogEventStats {
380        optional int32 tag = 1;
381        optional int64 elapsed_timestamp_nanos = 2;
382    }
383    repeated SkippedLogEventStats skipped_log_event_stats = 13;
384
385    repeated int64 log_loss_stats = 14;
386
387    repeated int32 system_restart_sec = 15;
388}
389