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"; 18option optimize_for = LITE_RUNTIME; 19 20import "perfetto/config/data_source_config.proto"; 21 22package perfetto.protos; 23 24// When editing this file run ./tools/gen_tracing_cpp_headers_from_protos 25// to reflect changes in the corresponding C++ headers. 26 27// The overall config that is used when starting a new tracing session through 28// ProducerPort::StartTracing(). 29// It contains the general config for the logging buffer(s) and the configs for 30// all the data source being enabled. 31// 32// Next id: 26. 33message TraceConfig { 34 message BufferConfig { 35 optional uint32 size_kb = 1; 36 37 reserved 2; // |page_size|, now deprecated. 38 reserved 3; // |optimize_for|, now deprecated. 39 40 enum FillPolicy { 41 UNSPECIFIED = 0; 42 43 // Default behavior. The buffer operates as a conventional ring buffer. 44 // If the writer is faster than the reader (or if the reader reads only 45 // after tracing is stopped) newly written packets will overwrite old 46 // packets. 47 RING_BUFFER = 1; 48 49 // Behaves like RING_BUFFER as long as there is space in the buffer or 50 // the reader catches up with the writer. As soon as the writer hits 51 // an unread chunk, it stops accepting new data in the buffer. 52 DISCARD = 2; 53 } 54 optional FillPolicy fill_policy = 4; 55 } 56 repeated BufferConfig buffers = 1; 57 58 message DataSource { 59 // Filters and data-source specific config. It contains also the unique name 60 // of the data source, the one passed in the DataSourceDescriptor when they 61 // register on the service. 62 optional protos.DataSourceConfig config = 1; 63 64 // Optional. If multiple producers (~processes) expose the same data source 65 // and |producer_name_filter| != "", the data source is enabled only for 66 // producers whose names match any of the producer_name_filter below. 67 // The |producer_name_filter| has to be an exact match. (TODO(primiano): 68 // support wildcards or regex). 69 // This allows to enable a data source only for specific processes. 70 // The "repeated" field has OR sematics: specifying a filter ["foo", "bar"] 71 // will enable data source on both "foo" and "bar" (if existent). 72 repeated string producer_name_filter = 2; 73 } 74 repeated DataSource data_sources = 2; 75 76 // Config for builtin trace packets emitted by perfetto like trace stats, 77 // system info, etc. 78 message BuiltinDataSource { 79 // Disable emitting clock timestamps into the trace. 80 optional bool disable_clock_snapshotting = 1; 81 82 optional bool disable_trace_config = 2; 83 84 optional bool disable_system_info = 3; 85 } 86 optional BuiltinDataSource builtin_data_sources = 20; 87 88 // If specified, the trace will be stopped |duration_ms| after starting. 89 // However in case of traces with triggers, see 90 // TriggerConfig.trigger_timeout_ms instead. 91 optional uint32 duration_ms = 3; 92 93 // This is set when --dropbox is passed to the Perfetto command line client 94 // and enables guardrails that limit resource usage for traces requested 95 // by statsd. 96 optional bool enable_extra_guardrails = 4; 97 98 enum LockdownModeOperation { 99 LOCKDOWN_UNCHANGED = 0; 100 LOCKDOWN_CLEAR = 1; 101 LOCKDOWN_SET = 2; 102 } 103 // Reject producers that are not running under the same UID as the tracing 104 // service. 105 optional LockdownModeOperation lockdown_mode = 5; 106 107 message ProducerConfig { 108 // Identifies the producer for which this config is for. 109 optional string producer_name = 1; 110 111 // Specifies the preferred size of the shared memory buffer. If the size is 112 // larger than the max size, the max will be used. If it is smaller than 113 // the page size or doesn't fit pages evenly into it, it will fall back to 114 // the size specified by the producer or finally the default shared memory 115 // size. 116 optional uint32 shm_size_kb = 2; 117 118 // Specifies the preferred size of each page in the shared memory buffer. 119 // Must be an integer multiple of 4K. 120 optional uint32 page_size_kb = 3; 121 } 122 123 repeated ProducerConfig producers = 6; 124 125 // Contains statsd-specific metadata about an alert associated with the trace. 126 message StatsdMetadata { 127 // The identifier of the alert which triggered this trace. 128 optional int64 triggering_alert_id = 1; 129 // The uid which registered the triggering configuration with statsd. 130 optional int32 triggering_config_uid = 2; 131 // The identifier of the config which triggered the alert. 132 optional int64 triggering_config_id = 3; 133 // The identifier of the subscription which triggered this trace. 134 optional int64 triggering_subscription_id = 4; 135 } 136 137 // Statsd-specific metadata. 138 optional StatsdMetadata statsd_metadata = 7; 139 140 // When true, the EnableTracing() request must also provide a file descriptor. 141 // The service will then periodically read packets out of the trace buffer and 142 // store it into the passed file. 143 optional bool write_into_file = 8; 144 145 // Optional. If non-zero tunes the write period. A min value of 100ms is 146 // enforced (i.e. smaller values are ignored). 147 optional uint32 file_write_period_ms = 9; 148 149 // Optional. When non zero the periodic write stops once at most X bytes 150 // have been written into the file. Tracing is disabled when this limit is 151 // reached, even if |duration_ms| has not been reached yet. 152 optional uint64 max_file_size_bytes = 10; 153 154 // Contains flags which override the default values of the guardrails inside 155 // Perfetto. These values are only affect userdebug builds. 156 message GuardrailOverrides { 157 // Override the default limit (in bytes) for uploading data to server within 158 // a 24 hour period. 159 optional uint64 max_upload_per_day_bytes = 1; 160 } 161 162 optional GuardrailOverrides guardrail_overrides = 11; 163 164 // When true, data sources are not started until an explicit call to 165 // StartTracing() on the consumer port. This is to support early 166 // initialization and fast trace triggering. This can be used only when the 167 // Consumer explicitly triggers the StartTracing() method. 168 // This should not be used in a remote trace config via statsd, doing so will 169 // result in a hung trace session. 170 optional bool deferred_start = 12; 171 172 // When set, it periodically issues a Flush() to all data source, forcing them 173 // to commit their data into the tracing service. This can be used for 174 // quasi-real-time streaming mode and to guarantee some partial ordering of 175 // events in the trace in windows of X ms. 176 optional uint32 flush_period_ms = 13; 177 178 // Wait for this long for producers to acknowledge flush requests. 179 // Default 5s. 180 optional uint32 flush_timeout_ms = 14; 181 182 reserved 15; // |disable_clock_snapshotting| moved. 183 184 // Android-only. If set, sends an intent to the Traceur system app when the 185 // trace ends to notify it about the trace readiness. 186 optional bool notify_traceur = 16; 187 188 // Triggers allow producers to start or stop the tracing session when an event 189 // occurs. 190 // 191 // For example if we are tracing probabilistically, most traces will be 192 // uninteresting. Triggers allow us to keep only the interesting ones such as 193 // those traces during which the device temperature reached a certain 194 // threshold. In this case the producer can activate a trigger to keep 195 // (STOP_TRACING) the trace, otherwise it can also begin a trace 196 // (START_TRACING) because it knows something is about to happen. 197 message TriggerConfig { 198 enum TriggerMode { 199 UNSPECIFIED = 0; 200 201 // When this mode is chosen, data sources are not started until one of the 202 // |triggers| are received. This supports early initialization and fast 203 // starting of the tracing system. On triggering, the session will then 204 // record for |stop_delay_ms|. However if no trigger is seen 205 // after |trigger_timeout_ms| the session will be stopped and no data will 206 // be returned. 207 START_TRACING = 1; 208 209 // When this mode is chosen, the session will be started via the normal 210 // EnableTracing() & StartTracing(). If no trigger is ever seen 211 // the session will be stopped after |trigger_timeout_ms| and no data will 212 // be returned. However if triggered the trace will stop after 213 // |stop_delay_ms| and any data in the buffer will be returned to the 214 // consumer. 215 STOP_TRACING = 2; 216 } 217 optional TriggerMode trigger_mode = 1; 218 219 message Trigger { 220 // The producer must specify this name to activate the trigger. 221 optional string name = 1; 222 223 // The a std::regex that will match the producer that can activate this 224 // trigger. This is optional. If unset any producers can activate this 225 // trigger. 226 optional string producer_name_regex = 2; 227 228 // After a trigger is received either in START_TRACING or STOP_TRACING 229 // mode then the trace will end |stop_delay_ms| after triggering. 230 optional uint32 stop_delay_ms = 3; 231 } 232 // A list of triggers which are related to this configuration. If ANY 233 // trigger is seen then an action will be performed based on |trigger_mode|. 234 repeated Trigger triggers = 2; 235 236 // Required and must be positive if a TriggerConfig is specified. This is 237 // how long this TraceConfig should wait for a trigger to arrive. After this 238 // period of time if no trigger is seen the TracingSession will be cleaned 239 // up. 240 optional uint32 trigger_timeout_ms = 3; 241 } 242 optional TriggerConfig trigger_config = 17; 243 244 // When this is non-empty the perfetto command line tool will ignore the rest 245 // of this TraceConfig and instead connect to the perfetto service as a 246 // producer and send these triggers, potentially stopping or starting traces 247 // that were previous configured to use a TriggerConfig. 248 repeated string activate_triggers = 18; 249 250 // Configuration for trace contents that reference earlier trace data. For 251 // example, a data source might intern strings, and emit packets containing 252 // {interned id : string} pairs. Future packets from that data source can then 253 // use the interned ids instead of duplicating the raw string contents. The 254 // trace parser will then need to use that interning table to fully interpret 255 // the rest of the trace. 256 message IncrementalStateConfig { 257 // If nonzero, notify eligible data sources to clear their incremental state 258 // periodically, with the given period. The notification is sent only to 259 // data sources that have |handles_incremental_state_clear| set in their 260 // DataSourceDescriptor. The notification requests that the data source 261 // stops referring to past trace contents. This is particularly useful when 262 // tracing in ring buffer mode, where it is not exceptional to overwrite old 263 // trace data. 264 // 265 // Warning: this time-based global clearing is likely to be removed in the 266 // future, to be replaced with a smarter way of sending the notifications 267 // only when necessary. 268 optional uint32 clear_period_ms = 1; 269 } 270 optional IncrementalStateConfig incremental_state_config = 21; 271 272 // Additional guardrail used by the Perfetto command line client. 273 // On user builds when --dropbox is set perfetto will refuse to trace unless 274 // this is also set. 275 // Added in Q. 276 optional bool allow_user_build_tracing = 19; 277 278 // If set the tracing service will ensure there is at most one tracing session 279 // with this key. 280 optional string unique_session_name = 22; 281 282 // Compress trace with the given method. Best effort. 283 enum CompressionType { 284 COMPRESSION_TYPE_UNSPECIFIED = 0; 285 COMPRESSION_TYPE_DEFLATE = 1; 286 }; 287 optional CompressionType compression_type = 24; 288 289 // Android-only. Debug builds only. Not for general use. If set, saves a 290 // Dropbox trace into an incident. This field is read by perfetto_cmd, rather 291 // than the tracing service. All fields are mandatory. 292 message IncidentReportConfig { 293 optional string destination_package = 1; 294 optional string destination_class = 2; 295 // Level of filtering in the requested incident. See |Destination| in 296 // frameworks/base/core/proto/android/privacy.proto. 297 optional int32 privacy_level = 3; 298 // If true, do not write the trace into dropbox (i.e. incident only). 299 // Otherwise, write to both dropbox and incident. 300 optional bool skip_dropbox = 4; 301 } 302 optional IncidentReportConfig incident_report_config = 25; 303} 304