1/*
2 * Copyright (C) 2021 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
17// Partial clone of frameworks/proto_logging/stats/atoms.proto. CarWatchdogService only uses small
18// number of atoms.
19
20syntax = "proto2";
21
22package android.car.watchdog.statsd;
23option java_package = "com.android.car.watchdog";
24option java_outer_classname = "AtomsProto";
25
26/**
27 * Logs the current state of an application/process before it is killed.
28 *
29 * Keep in sync with proto file at frameworks/proto_logging/stats/atoms.proto
30 */
31message CarWatchdogKillStatsReported {
32  // Linux process uid for the package.
33  optional int32 uid = 1;
34
35  // State of the uid when it was killed.
36  enum UidState {
37    UNKNOWN_UID_STATE = 0;
38    BACKGROUND_MODE = 1;
39    FOREGROUND_MODE = 2;
40  }
41  optional UidState uid_state = 2;
42
43  // System state indicating whether the system was in normal mode or garage mode.
44  enum SystemState {
45    UNKNOWN_SYSTEM_STATE = 0;
46    USER_INTERACTION_MODE = 1;
47    USER_NO_INTERACTION_MODE = 2;
48    GARAGE_MODE = 3;
49  }
50  optional SystemState system_state = 3;
51
52  // Reason for killing the application.
53  // Keep in sync with proto file at packages/services/Car/cpp/watchdog/proto
54  enum KillReason {
55    UNKNOWN_KILL_REASON = 0;
56    KILLED_ON_ANR = 1;
57    KILLED_ON_IO_OVERUSE = 2;
58    KILLED_ON_MEMORY_OVERUSE = 3;
59  }
60  optional KillReason kill_reason = 4;
61
62  // Stats of the processes owned by the application when the application was killed.
63  // The process stack traces are not collected when the application was killed due to IO_OVERUSE.
64  optional CarWatchdogProcessStats process_stats = 5;
65
66  // The application's I/O overuse stats logged only when the kill reason is KILLED_ON_IO_OVERUSE.
67  optional CarWatchdogIoOveruseStats io_overuse_stats = 6;
68}
69
70/**
71 * Logs the I/O overuse stats for an application on detecting I/O overuse.
72 *
73 * Keep in sync with proto file at frameworks/proto_logging/stats/atoms.proto
74 */
75message CarWatchdogIoOveruseStatsReported {
76  // Linux process uid for the package.
77  optional int32 uid = 1;
78
79  // The application's I/O overuse stats.
80  optional CarWatchdogIoOveruseStats io_overuse_stats = 2;
81}
82
83/**
84 * Logs I/O overuse stats for a package.
85 *
86 * Keep in sync with proto file at frameworks/proto_logging/stats/atoms.proto
87 */
88message CarWatchdogIoOveruseStats {
89  enum Period {
90    UNKNOWN_PERIOD = 0;
91    DAILY = 1;
92    WEEKLY = 2;
93  }
94
95  // Threshold and usage stats period.
96  optional Period period = 1;
97
98  // Threshold in-terms of write bytes defined for the package.
99  optional CarWatchdogPerStateBytes threshold = 2;
100
101  // Number of write bytes in each state for the specified period.
102  optional CarWatchdogPerStateBytes written_bytes = 3;
103
104  // Application or service uptime during the aforemetioned period.
105  optional uint64 uptime_millis = 4;
106};
107
108/**
109 * Logs bytes attributed to each application and system states.
110 *
111 * Keep in sync with proto file at frameworks/proto_logging/stats/atoms.proto
112 */
113message CarWatchdogPerStateBytes {
114  // Number of bytes attributed to the application foreground.
115  optional int64 foreground_bytes = 1;
116
117  // Number of bytes attributed to the application background.
118  optional int64 background_bytes = 2;
119
120  // Number of bytes attributed to the garage mode.
121  optional int64 garage_mode_bytes = 3;
122}
123
124/**
125 * Logs each CarWatchdogProcessStat in CarWatchdogProcessStats.
126 *
127 * Keep in sync with proto file at frameworks/proto_logging/stats/atoms.proto
128 */
129message CarWatchdogProcessStats {
130  // Records the stats of the processes owned by an application.
131  repeated CarWatchdogProcessStat process_stat = 1;
132}
133
134/**
135 * Logs a process's stats.
136 *
137 * Keep in sync with proto file at frameworks/proto_logging/stats/atoms.proto
138 */
139message CarWatchdogProcessStat {
140  // Command name of the process.
141  optional string process_name = 1;
142
143  // Process uptime.
144  optional uint64 uptime_millis = 2;
145
146  // Number of major page faults caused by the process and its children.
147  optional uint64 major_page_faults = 3;
148
149  // Peak virtual memory size in kb.
150  optional uint64 vm_peak_kb = 4;
151
152  // Virtual memory size in kb.
153  optional uint64 vm_size_kb = 5;
154
155  // Peak resident set size (high water mark) in kb.
156  optional uint64 vm_hwm_kb = 6;
157
158  // Resident set size in kb.
159  optional uint64 vm_rss_kb = 7;
160}
161
162/**
163 * Logs total I/O usage summary for all applications and services running in the system.
164 *
165 * Keep in sync with proto file at
166 * packages/services/Car/service/src/com/android/car/watchdog/proto/atoms.proto
167 *
168 * Pulled from:
169 *  packages/services/Car/service/src/com/android/car/watchdog/WatchdogPerfHandler.java
170 */
171message CarWatchdogSystemIoUsageSummary {
172  // I/O usage summary for the system.
173  optional CarWatchdogIoUsageSummary io_usage_summary = 1;
174}
175
176/**
177 * Logs I/O usage summary for an UID.
178 *
179 * Keep in sync with proto file at
180 * packages/services/Car/service/src/com/android/car/watchdog/proto/atoms.proto
181 *
182 * Pulled from:
183 *  packages/services/Car/service/src/com/android/car/watchdog/WatchdogPerfHandler.java
184 */
185message CarWatchdogUidIoUsageSummary {
186  // UID of the application/service whose usage summary are recorded.
187  optional int32 uid = 1;
188
189  // I/O usage summary for the UID.
190  optional CarWatchdogIoUsageSummary io_usage_summary = 2;
191}
192
193/**
194 * Logs I/O usage summary for a time period.
195 *
196 * Keep in sync with proto file at
197 * packages/services/Car/service/src/com/android/car/watchdog/proto/atoms.proto
198 *
199 * Pulled from:
200 *  packages/services/Car/service/src/com/android/car/watchdog/WatchdogPerfHandler.java
201 */
202message CarWatchdogIoUsageSummary {
203  // Summary event time period.
204  optional CarWatchdogEventTimePeriod event_time_period = 1;
205
206  // Daily I/O usage summary for the period. Logs summary entries only for days with I/O usage.
207  // The entries are ordered beginning from the event_time_period.start_time_millis.
208  repeated CarWatchdogDailyIoUsageSummary daily_io_usage_summary = 2;
209}
210
211/**
212 * Logs a car watchdog event's time period.
213 *
214 * Keep in sync with proto file at
215 * packages/services/Car/service/src/com/android/car/watchdog/proto/atoms.proto
216 *
217 * Pulled from:
218 *  packages/services/Car/service/src/com/android/car/watchdog/WatchdogPerfHandler.java
219 */
220message CarWatchdogEventTimePeriod {
221  enum Period {
222    UNKNOWN_PERIOD = 0;
223    WEEKLY = 1;
224    BIWEEKLY = 2;
225    MONTHLY = 3;
226  }
227
228  // Start time of the event in milliseconds since epoch.
229  optional uint64 start_time_millis = 1;
230
231  // Period for the event.
232  optional Period period = 2;
233}
234
235/**
236 * Logs daily I/O usage summary.
237 *
238 * Keep in sync with proto file at
239 * packages/services/Car/service/src/com/android/car/watchdog/proto/atoms.proto
240 *
241 * Pulled from:
242 *  packages/services/Car/service/src/com/android/car/watchdog/WatchdogPerfHandler.java
243 */
244message CarWatchdogDailyIoUsageSummary {
245  // Total bytes written to disk during a day.
246  optional CarWatchdogPerStateBytes written_bytes = 1;
247
248  // Total uptime for the system or service or application during a day.
249  optional uint64 uptime_millis = 2;
250
251  // Total disk I/O overuses during a day.
252  optional int32 overuse_count = 3;
253}
254