Home | History | Annotate | Download | only in config
      1 // AUTOGENERATED - DO NOT EDIT
      2 // ---------------------------
      3 // This file has been generated by
      4 // AOSP://external/perfetto/tools/gen_merged_protos
      5 // merging the perfetto config protos.
      6 // This fused proto is intended to be copied in:
      7 //  - Android tree, for statsd.
      8 //  - Google internal repos.
      9 
     10 syntax = "proto2";
     11 
     12 package perfetto.protos;
     13 
     14 // Begin of protos/perfetto/common/android_log_constants.proto
     15 
     16 // Values from NDK's android/log.h.
     17 enum AndroidLogId {
     18   LID_DEFAULT = 0;  // MAIN.
     19   LID_RADIO = 1;
     20   LID_EVENTS = 2;
     21   LID_SYSTEM = 3;
     22   LID_CRASH = 4;
     23   LID_STATS = 5;
     24   LID_SECURITY = 6;
     25   LID_KERNEL = 7;
     26 }
     27 
     28 enum AndroidLogPriority {
     29   PRIO_UNSPECIFIED = 0;
     30   PRIO_UNUSED = 1;  // _DEFAULT, but should never be seen in logs.
     31   PRIO_VERBOSE = 2;
     32   PRIO_DEBUG = 3;
     33   PRIO_INFO = 4;
     34   PRIO_WARN = 5;
     35   PRIO_ERROR = 6;
     36   PRIO_FATAL = 7;
     37 }
     38 
     39 // End of protos/perfetto/common/android_log_constants.proto
     40 
     41 // Begin of protos/perfetto/common/sys_stats_counters.proto
     42 
     43 // When editing entries here remember also to update "sys_stats_counters.h" with
     44 // the corresponding string definitions for the actual /proc files parser.
     45 
     46 // Counter definitions for Linux's /proc/meminfo.
     47 enum MeminfoCounters {
     48   MEMINFO_UNSPECIFIED = 0;
     49   MEMINFO_MEM_TOTAL = 1;
     50   MEMINFO_MEM_FREE = 2;
     51   MEMINFO_MEM_AVAILABLE = 3;
     52   MEMINFO_BUFFERS = 4;
     53   MEMINFO_CACHED = 5;
     54   MEMINFO_SWAP_CACHED = 6;
     55   MEMINFO_ACTIVE = 7;
     56   MEMINFO_INACTIVE = 8;
     57   MEMINFO_ACTIVE_ANON = 9;
     58   MEMINFO_INACTIVE_ANON = 10;
     59   MEMINFO_ACTIVE_FILE = 11;
     60   MEMINFO_INACTIVE_FILE = 12;
     61   MEMINFO_UNEVICTABLE = 13;
     62   MEMINFO_MLOCKED = 14;
     63   MEMINFO_SWAP_TOTAL = 15;
     64   MEMINFO_SWAP_FREE = 16;
     65   MEMINFO_DIRTY = 17;
     66   MEMINFO_WRITEBACK = 18;
     67   MEMINFO_ANON_PAGES = 19;
     68   MEMINFO_MAPPED = 20;
     69   MEMINFO_SHMEM = 21;
     70   MEMINFO_SLAB = 22;
     71   MEMINFO_SLAB_RECLAIMABLE = 23;
     72   MEMINFO_SLAB_UNRECLAIMABLE = 24;
     73   MEMINFO_KERNEL_STACK = 25;
     74   MEMINFO_PAGE_TABLES = 26;
     75   MEMINFO_COMMIT_LIMIT = 27;
     76   MEMINFO_COMMITED_AS = 28;
     77   MEMINFO_VMALLOC_TOTAL = 29;
     78   MEMINFO_VMALLOC_USED = 30;
     79   MEMINFO_VMALLOC_CHUNK = 31;
     80   MEMINFO_CMA_TOTAL = 32;
     81   MEMINFO_CMA_FREE = 33;
     82 }
     83 
     84 // Counter definitions for Linux's /proc/vmstat.
     85 enum VmstatCounters {
     86   VMSTAT_UNSPECIFIED = 0;
     87   VMSTAT_NR_FREE_PAGES = 1;
     88   VMSTAT_NR_ALLOC_BATCH = 2;
     89   VMSTAT_NR_INACTIVE_ANON = 3;
     90   VMSTAT_NR_ACTIVE_ANON = 4;
     91   VMSTAT_NR_INACTIVE_FILE = 5;
     92   VMSTAT_NR_ACTIVE_FILE = 6;
     93   VMSTAT_NR_UNEVICTABLE = 7;
     94   VMSTAT_NR_MLOCK = 8;
     95   VMSTAT_NR_ANON_PAGES = 9;
     96   VMSTAT_NR_MAPPED = 10;
     97   VMSTAT_NR_FILE_PAGES = 11;
     98   VMSTAT_NR_DIRTY = 12;
     99   VMSTAT_NR_WRITEBACK = 13;
    100   VMSTAT_NR_SLAB_RECLAIMABLE = 14;
    101   VMSTAT_NR_SLAB_UNRECLAIMABLE = 15;
    102   VMSTAT_NR_PAGE_TABLE_PAGES = 16;
    103   VMSTAT_NR_KERNEL_STACK = 17;
    104   VMSTAT_NR_OVERHEAD = 18;
    105   VMSTAT_NR_UNSTABLE = 19;
    106   VMSTAT_NR_BOUNCE = 20;
    107   VMSTAT_NR_VMSCAN_WRITE = 21;
    108   VMSTAT_NR_VMSCAN_IMMEDIATE_RECLAIM = 22;
    109   VMSTAT_NR_WRITEBACK_TEMP = 23;
    110   VMSTAT_NR_ISOLATED_ANON = 24;
    111   VMSTAT_NR_ISOLATED_FILE = 25;
    112   VMSTAT_NR_SHMEM = 26;
    113   VMSTAT_NR_DIRTIED = 27;
    114   VMSTAT_NR_WRITTEN = 28;
    115   VMSTAT_NR_PAGES_SCANNED = 29;
    116   VMSTAT_WORKINGSET_REFAULT = 30;
    117   VMSTAT_WORKINGSET_ACTIVATE = 31;
    118   VMSTAT_WORKINGSET_NODERECLAIM = 32;
    119   VMSTAT_NR_ANON_TRANSPARENT_HUGEPAGES = 33;
    120   VMSTAT_NR_FREE_CMA = 34;
    121   VMSTAT_NR_SWAPCACHE = 35;
    122   VMSTAT_NR_DIRTY_THRESHOLD = 36;
    123   VMSTAT_NR_DIRTY_BACKGROUND_THRESHOLD = 37;
    124   VMSTAT_PGPGIN = 38;
    125   VMSTAT_PGPGOUT = 39;
    126   VMSTAT_PGPGOUTCLEAN = 40;
    127   VMSTAT_PSWPIN = 41;
    128   VMSTAT_PSWPOUT = 42;
    129   VMSTAT_PGALLOC_DMA = 43;
    130   VMSTAT_PGALLOC_NORMAL = 44;
    131   VMSTAT_PGALLOC_MOVABLE = 45;
    132   VMSTAT_PGFREE = 46;
    133   VMSTAT_PGACTIVATE = 47;
    134   VMSTAT_PGDEACTIVATE = 48;
    135   VMSTAT_PGFAULT = 49;
    136   VMSTAT_PGMAJFAULT = 50;
    137   VMSTAT_PGREFILL_DMA = 51;
    138   VMSTAT_PGREFILL_NORMAL = 52;
    139   VMSTAT_PGREFILL_MOVABLE = 53;
    140   VMSTAT_PGSTEAL_KSWAPD_DMA = 54;
    141   VMSTAT_PGSTEAL_KSWAPD_NORMAL = 55;
    142   VMSTAT_PGSTEAL_KSWAPD_MOVABLE = 56;
    143   VMSTAT_PGSTEAL_DIRECT_DMA = 57;
    144   VMSTAT_PGSTEAL_DIRECT_NORMAL = 58;
    145   VMSTAT_PGSTEAL_DIRECT_MOVABLE = 59;
    146   VMSTAT_PGSCAN_KSWAPD_DMA = 60;
    147   VMSTAT_PGSCAN_KSWAPD_NORMAL = 61;
    148   VMSTAT_PGSCAN_KSWAPD_MOVABLE = 62;
    149   VMSTAT_PGSCAN_DIRECT_DMA = 63;
    150   VMSTAT_PGSCAN_DIRECT_NORMAL = 64;
    151   VMSTAT_PGSCAN_DIRECT_MOVABLE = 65;
    152   VMSTAT_PGSCAN_DIRECT_THROTTLE = 66;
    153   VMSTAT_PGINODESTEAL = 67;
    154   VMSTAT_SLABS_SCANNED = 68;
    155   VMSTAT_KSWAPD_INODESTEAL = 69;
    156   VMSTAT_KSWAPD_LOW_WMARK_HIT_QUICKLY = 70;
    157   VMSTAT_KSWAPD_HIGH_WMARK_HIT_QUICKLY = 71;
    158   VMSTAT_PAGEOUTRUN = 72;
    159   VMSTAT_ALLOCSTALL = 73;
    160   VMSTAT_PGROTATED = 74;
    161   VMSTAT_DROP_PAGECACHE = 75;
    162   VMSTAT_DROP_SLAB = 76;
    163   VMSTAT_PGMIGRATE_SUCCESS = 77;
    164   VMSTAT_PGMIGRATE_FAIL = 78;
    165   VMSTAT_COMPACT_MIGRATE_SCANNED = 79;
    166   VMSTAT_COMPACT_FREE_SCANNED = 80;
    167   VMSTAT_COMPACT_ISOLATED = 81;
    168   VMSTAT_COMPACT_STALL = 82;
    169   VMSTAT_COMPACT_FAIL = 83;
    170   VMSTAT_COMPACT_SUCCESS = 84;
    171   VMSTAT_COMPACT_DAEMON_WAKE = 85;
    172   VMSTAT_UNEVICTABLE_PGS_CULLED = 86;
    173   VMSTAT_UNEVICTABLE_PGS_SCANNED = 87;
    174   VMSTAT_UNEVICTABLE_PGS_RESCUED = 88;
    175   VMSTAT_UNEVICTABLE_PGS_MLOCKED = 89;
    176   VMSTAT_UNEVICTABLE_PGS_MUNLOCKED = 90;
    177   VMSTAT_UNEVICTABLE_PGS_CLEARED = 91;
    178   VMSTAT_UNEVICTABLE_PGS_STRANDED = 92;
    179 }
    180 // End of protos/perfetto/common/sys_stats_counters.proto
    181 
    182 // Begin of protos/perfetto/config/android/android_log_config.proto
    183 
    184 message AndroidLogConfig {
    185   repeated AndroidLogId log_ids = 1;
    186 
    187   reserved 2;  // Was |poll_ms|, deprecated.
    188 
    189   // If set ignores all log messages whose prio is < the given value.
    190   optional AndroidLogPriority min_prio = 3;
    191 
    192   // If non-empty ignores all log messages whose tag doesn't match one of the
    193   // specified values.
    194   repeated string filter_tags = 4;
    195 }
    196 
    197 // End of protos/perfetto/config/android/android_log_config.proto
    198 
    199 // Begin of protos/perfetto/config/chrome/chrome_config.proto
    200 
    201 // When editing this file run ./tools/gen_tracing_cpp_headers_from_protos.py
    202 // to reflect changes in the corresponding C++ headers.
    203 
    204 message ChromeConfig {
    205   optional string trace_config = 1;
    206 
    207   // When enabled, the data source should only fill in fields in the output that
    208   // are not potentially privacy sensitive.
    209   optional bool privacy_filtering_enabled = 2;
    210 }
    211 
    212 // End of protos/perfetto/config/chrome/chrome_config.proto
    213 
    214 // Begin of protos/perfetto/config/data_source_config.proto
    215 
    216 // When editing this file run ./tools/gen_tracing_cpp_headers_from_protos.py
    217 // to reflect changes in the corresponding C++ headers.
    218 
    219 // The configuration that is passed to each data source when starting tracing.
    220 message DataSourceConfig {
    221   // Data source unique name, e.g., "linux.ftrace". This must match
    222   // the name passed by the data source when it registers (see
    223   // RegisterDataSource()).
    224   optional string name = 1;
    225 
    226   // The index of the logging buffer where TracePacket(s) will be stored.
    227   // This field doesn't make a major difference for the Producer(s). The final
    228   // logging buffers, in fact, are completely owned by the Service. We just ask
    229   // the Producer to copy this number into the chunk headers it emits, so that
    230   // the Service can quickly identify the buffer where to move the chunks into
    231   // without expensive lookups on its fastpath.
    232   optional uint32 target_buffer = 2;
    233 
    234   // Set by the service to indicate the duration of the trace.
    235   // DO NOT SET in consumer as this will be overridden by the service.
    236   optional uint32 trace_duration_ms = 3;
    237 
    238   // Set by the service to indicate whether this tracing session has extra
    239   // guardrails.
    240   // DO NOT SET in consumer as this will be overridden by the service.
    241   optional bool enable_extra_guardrails = 6;
    242 
    243   // Set by the service to indicate which tracing session the data source
    244   // belongs to. The intended use case for this is checking if two data sources,
    245   // one of which produces metadata for the other one, belong to the same trace
    246   // session and hence should be linked together.
    247   // This field was introduced in Aug 2018 after Android P.
    248   optional uint64 tracing_session_id = 4;
    249 
    250   // Keeep the lower IDs (up to 99) for fields that are *not* specific to
    251   // data-sources and needs to be processed by the traced daemon.
    252 
    253   optional FtraceConfig ftrace_config = 100;
    254   optional ChromeConfig chrome_config = 101;
    255   optional InodeFileConfig inode_file_config = 102;
    256   optional ProcessStatsConfig process_stats_config = 103;
    257   optional SysStatsConfig sys_stats_config = 104;
    258   optional HeapprofdConfig heapprofd_config = 105;
    259   optional AndroidPowerConfig android_power_config = 106;
    260   optional AndroidLogConfig android_log_config = 107;
    261   optional PackagesListConfig packages_list_config = 109;
    262 
    263   // This is a fallback mechanism to send a free-form text config to the
    264   // producer. In theory this should never be needed. All the code that
    265   // is part of the platform (i.e. traced service) is supposed to *not* truncate
    266   // the trace config proto and propagate unknown fields. However, if anything
    267   // in the pipeline (client or backend) ends up breaking this forward compat
    268   // plan, this field will become the escape hatch to allow future data sources
    269   // to get some meaningful configuration.
    270   optional string legacy_config = 1000;
    271 
    272   // This field is only used for testing.
    273   optional TestConfig for_testing =
    274       268435455;  // 2^28 - 1, max field id for protos supported by Java.
    275 }
    276 
    277 // End of protos/perfetto/config/data_source_config.proto
    278 
    279 // Begin of protos/perfetto/config/ftrace/ftrace_config.proto
    280 
    281 // When editing this file run ./tools/gen_tracing_cpp_headers_from_protos.py
    282 // to reflect changes in the corresponding C++ headers.
    283 
    284 message FtraceConfig {
    285   repeated string ftrace_events = 1;
    286   repeated string atrace_categories = 2;
    287   repeated string atrace_apps = 3;
    288   // *Per-CPU* buffer size.
    289   optional uint32 buffer_size_kb = 10;
    290   optional uint32 drain_period_ms = 11;
    291 }
    292 
    293 // End of protos/perfetto/config/ftrace/ftrace_config.proto
    294 
    295 // Begin of protos/perfetto/config/inode_file/inode_file_config.proto
    296 
    297 // When editing this file run ./tools/gen_tracing_cpp_headers_from_protos.py
    298 // to reflect changes in the corresponding C++ headers.
    299 
    300 message InodeFileConfig {
    301   message MountPointMappingEntry {
    302     optional string mountpoint = 1;
    303     repeated string scan_roots = 2;
    304   }
    305 
    306   // How long to pause between batches.
    307   optional uint32 scan_interval_ms = 1;
    308 
    309   // How long to wait before the first scan in order to accumulate inodes.
    310   optional uint32 scan_delay_ms = 2;
    311 
    312   // How many inodes to scan in one batch.
    313   optional uint32 scan_batch_size = 3;
    314 
    315   // Do not scan for inodes not found in the static map.
    316   optional bool do_not_scan = 4;
    317 
    318   // If non-empty, only scan inodes corresponding to block devices named in
    319   // this list.
    320   repeated string scan_mount_points = 5;
    321 
    322   // When encountering an inode belonging to a block device corresponding
    323   // to one of the mount points in this map, scan its scan_roots instead.
    324   repeated MountPointMappingEntry mount_point_mapping = 6;
    325 }
    326 
    327 // End of protos/perfetto/config/inode_file/inode_file_config.proto
    328 
    329 // Begin of protos/perfetto/config/power/android_power_config.proto
    330 
    331 message AndroidPowerConfig {
    332   enum BatteryCounters {
    333     BATTERY_COUNTER_UNSPECIFIED = 0;
    334     BATTERY_COUNTER_CHARGE = 1;            // Coulomb counter.
    335     BATTERY_COUNTER_CAPACITY_PERCENT = 2;  // Charge (%).
    336     BATTERY_COUNTER_CURRENT = 3;           // Instantaneous current.
    337     BATTERY_COUNTER_CURRENT_AVG = 4;       // Avg current.
    338   }
    339   optional uint32 battery_poll_ms = 1;
    340   repeated BatteryCounters battery_counters = 2;
    341 
    342   // Where available enables per-power-rail measurements.
    343   optional bool collect_power_rails = 3;
    344 }
    345 
    346 // End of protos/perfetto/config/power/android_power_config.proto
    347 
    348 // Begin of protos/perfetto/config/process_stats/process_stats_config.proto
    349 
    350 // When editing this file run ./tools/gen_tracing_cpp_headers_from_protos.py
    351 // to reflect changes in the corresponding C++ headers.
    352 
    353 message ProcessStatsConfig {
    354   enum Quirks {
    355     QUIRKS_UNSPECIFIED = 0;
    356 
    357     // This has been deprecated and ignored as per 2018-05-01. Full scan at
    358     // startup is now disabled by default and can be re-enabled using the
    359     // |scan_all_processes_on_start| arg.
    360     DISABLE_INITIAL_DUMP = 1 [deprecated = true];
    361 
    362     DISABLE_ON_DEMAND = 2;
    363   }
    364 
    365   repeated Quirks quirks = 1;
    366 
    367   // If enabled all processes will be scanned and dumped when the trace starts.
    368   optional bool scan_all_processes_on_start = 2;
    369 
    370   // If enabled thread names are also recoded (this is redundant if sched_switch
    371   // is enabled).
    372   optional bool record_thread_names = 3;
    373 
    374   // If > 0 samples counters (see process_stats.proto) from
    375   // /proc/pid/status and oom_score_adj every X ms.
    376   // This is required to be > 100ms to avoid excessive CPU usage.
    377   // TODO(primiano): add CPU cost for change this value.
    378   optional uint32 proc_stats_poll_ms = 4;
    379 
    380   // If empty samples stats for all processes. If non empty samples stats only
    381   // for processes matching the given string in their argv0 (i.e. the first
    382   // entry of /proc/pid/cmdline).
    383   // TODO(primiano): implement this feature.
    384   // repeated string proc_stats_filter = 5;
    385 
    386   // This is required to be either = 0 or a multiple of |proc_stats_poll_ms|
    387   // (default: |proc_stats_poll_ms|). If = 0, will be set to
    388   // |proc_stats_poll_ms|. Non-multiples will be rounded down to the nearest
    389   // multiple.
    390   optional uint32 proc_stats_cache_ttl_ms = 6;
    391 }
    392 
    393 // End of protos/perfetto/config/process_stats/process_stats_config.proto
    394 
    395 // Begin of protos/perfetto/config/sys_stats/sys_stats_config.proto
    396 
    397 // When editing this file run ./tools/gen_tracing_cpp_headers_from_protos.py
    398 // to reflect changes in the corresponding C++ headers.
    399 
    400 // This file defines the configuration for the Linux /proc poller data source,
    401 // which injects counters in the trace.
    402 // Counters that are needed in the trace must be explicitly listed in the
    403 // *_counters fields. This is to avoid spamming the trace with all counters
    404 // at all times.
    405 // The sampling rate is configurable. All polling rates (*_period_ms) need
    406 // to be integer multiples of each other.
    407 // OK:     [10ms, 10ms, 10ms],  [10ms, 20ms, 10ms],  [10ms, 20ms, 60ms]
    408 // Not OK: [10ms, 10ms, 11ms],  [10ms, 15ms, 20ms]
    409 message SysStatsConfig {
    410   // Polls /proc/meminfo every X ms, if non-zero.
    411   // This is required to be > 10ms to avoid excessive CPU usage.
    412   // Cost: 0.3 ms [read] + 0.07 ms [parse + trace injection]
    413   optional uint32 meminfo_period_ms = 1;
    414 
    415   // Only the counters specified below are reported.
    416   repeated MeminfoCounters meminfo_counters = 2;
    417 
    418   // Polls /proc/vmstat every X ms, if non-zero.
    419   // This is required to be > 10ms to avoid excessive CPU usage.
    420   // Cost: 0.2 ms [read] + 0.3 ms [parse + trace injection]
    421   optional uint32 vmstat_period_ms = 3;
    422   repeated VmstatCounters vmstat_counters = 4;
    423 
    424   // Pols /proc/stat every X ms, if non-zero.
    425   // This is required to be > 10ms to avoid excessive CPU usage.
    426   // Cost: 4.1 ms [read] + 1.9 ms [parse + trace injection]
    427   optional uint32 stat_period_ms = 5;
    428   enum StatCounters {
    429     STAT_UNSPECIFIED = 0;
    430     STAT_CPU_TIMES = 1;
    431     STAT_IRQ_COUNTS = 2;
    432     STAT_SOFTIRQ_COUNTS = 3;
    433     STAT_FORK_COUNT = 4;
    434   }
    435   repeated StatCounters stat_counters = 6;
    436 }
    437 
    438 // End of protos/perfetto/config/sys_stats/sys_stats_config.proto
    439 
    440 // Begin of protos/perfetto/config/test_config.proto
    441 
    442 // When editing this file run ./tools/gen_tracing_cpp_headers_from_protos.py
    443 // to reflect changes in the corresponding C++ headers.
    444 
    445 // The configuration for a fake producer used in tests.
    446 message TestConfig {
    447   message DummyFields {
    448     optional uint32 field_uint32 = 1;
    449     optional int32 field_int32 = 2;
    450     optional uint64 field_uint64 = 3;
    451     optional int64 field_int64 = 4;
    452     optional fixed64 field_fixed64 = 5;
    453     optional sfixed64 field_sfixed64 = 6;
    454     optional fixed32 field_fixed32 = 7;
    455     optional sfixed32 field_sfixed32 = 8;
    456     optional double field_double = 9;
    457     optional float field_float = 10;
    458     optional sint64 field_sint64 = 11;
    459     optional sint32 field_sint32 = 12;
    460     optional string field_string = 13;
    461     optional bytes field_bytes = 14;
    462   }
    463 
    464   // The number of messages the fake producer should send.
    465   optional uint32 message_count = 1;
    466 
    467   // The maximum number of messages which should be sent each second.
    468   // The actual obserced speed may be lower if the producer is unable to
    469   // work fast enough.
    470   // If this is zero or unset, the producer will send as fast as possible.
    471   optional uint32 max_messages_per_second = 2;
    472 
    473   // The seed value for a simple multiplicative congruential pseudo-random
    474   // number sequence.
    475   optional uint32 seed = 3;
    476 
    477   // The size of each message in bytes. Should be greater than or equal 5 to
    478   // account for the number of bytes needed to encode the random number and a
    479   // null byte for the string.
    480   optional uint32 message_size = 4;
    481 
    482   // Whether the producer should send a event batch when the data source is
    483   // is initially registered.
    484   optional bool send_batch_on_register = 5;
    485 
    486   optional DummyFields dummy_fields = 6;
    487 }
    488 
    489 // End of protos/perfetto/config/test_config.proto
    490 
    491 // Begin of protos/perfetto/config/trace_config.proto
    492 
    493 // When editing this file run ./tools/gen_tracing_cpp_headers_from_protos
    494 // to reflect changes in the corresponding C++ headers.
    495 
    496 // The overall config that is used when starting a new tracing session through
    497 // ProducerPort::StartTracing().
    498 // It contains the general config for the logging buffer(s) and the configs for
    499 // all the data source being enabled.
    500 //
    501 // Next id: 26.
    502 message TraceConfig {
    503   message BufferConfig {
    504     optional uint32 size_kb = 1;
    505 
    506     reserved 2;  // |page_size|, now deprecated.
    507     reserved 3;  // |optimize_for|, now deprecated.
    508 
    509     enum FillPolicy {
    510       UNSPECIFIED = 0;
    511 
    512       // Default behavior. The buffer operates as a conventional ring buffer.
    513       // If the writer is faster than the reader (or if the reader reads only
    514       // after tracing is stopped) newly written packets will overwrite old
    515       // packets.
    516       RING_BUFFER = 1;
    517 
    518       // Behaves like RING_BUFFER as long as there is space in the buffer or
    519       // the reader catches up with the writer. As soon as the writer hits
    520       // an unread chunk, it stops accepting new data in the buffer.
    521       DISCARD = 2;
    522     }
    523     optional FillPolicy fill_policy = 4;
    524   }
    525   repeated BufferConfig buffers = 1;
    526 
    527   message DataSource {
    528     // Filters and data-source specific config. It contains also the unique name
    529     // of the data source, the one passed in the  DataSourceDescriptor when they
    530     // register on the service.
    531     optional protos.DataSourceConfig config = 1;
    532 
    533     // Optional. If multiple producers (~processes) expose the same data source
    534     // and |producer_name_filter| != "", the data source is enabled only for
    535     // producers whose names match any of the producer_name_filter below.
    536     // The |producer_name_filter| has to be an exact match. (TODO(primiano):
    537     // support wildcards or regex).
    538     // This allows to enable a data source only for specific processes.
    539     // The "repeated" field has OR sematics: specifying a filter ["foo", "bar"]
    540     // will enable data source on both "foo" and "bar" (if existent).
    541     repeated string producer_name_filter = 2;
    542   }
    543   repeated DataSource data_sources = 2;
    544 
    545   // Config for builtin trace packets emitted by perfetto like trace stats,
    546   // system info, etc.
    547   message BuiltinDataSource {
    548     // Disable emitting clock timestamps into the trace.
    549     optional bool disable_clock_snapshotting = 1;
    550 
    551     optional bool disable_trace_config = 2;
    552 
    553     optional bool disable_system_info = 3;
    554   }
    555   optional BuiltinDataSource builtin_data_sources = 20;
    556 
    557   // If specified, the trace will be stopped |duration_ms| after starting.
    558   // However in case of traces with triggers, see
    559   // TriggerConfig.trigger_timeout_ms instead.
    560   optional uint32 duration_ms = 3;
    561 
    562   // This is set when --dropbox is passed to the Perfetto command line client
    563   // and enables guardrails that limit resource usage for traces requested
    564   // by statsd.
    565   optional bool enable_extra_guardrails = 4;
    566 
    567   enum LockdownModeOperation {
    568     LOCKDOWN_UNCHANGED = 0;
    569     LOCKDOWN_CLEAR = 1;
    570     LOCKDOWN_SET = 2;
    571   }
    572   // Reject producers that are not running under the same UID as the tracing
    573   // service.
    574   optional LockdownModeOperation lockdown_mode = 5;
    575 
    576   message ProducerConfig {
    577     // Identifies the producer for which this config is for.
    578     optional string producer_name = 1;
    579 
    580     // Specifies the preferred size of the shared memory buffer. If the size is
    581     // larger than the max size, the max will be used. If it is smaller than
    582     // the page size or doesn't fit pages evenly into it, it will fall back to
    583     // the size specified by the producer or finally the default shared memory
    584     // size.
    585     optional uint32 shm_size_kb = 2;
    586 
    587     // Specifies the preferred size of each page in the shared memory buffer.
    588     // Must be an integer multiple of 4K.
    589     optional uint32 page_size_kb = 3;
    590   }
    591 
    592   repeated ProducerConfig producers = 6;
    593 
    594   // Contains statsd-specific metadata about an alert associated with the trace.
    595   message StatsdMetadata {
    596     // The identifier of the alert which triggered this trace.
    597     optional int64 triggering_alert_id = 1;
    598     // The uid which registered the triggering configuration with statsd.
    599     optional int32 triggering_config_uid = 2;
    600     // The identifier of the config which triggered the alert.
    601     optional int64 triggering_config_id = 3;
    602     // The identifier of the subscription which triggered this trace.
    603     optional int64 triggering_subscription_id = 4;
    604   }
    605 
    606   // Statsd-specific metadata.
    607   optional StatsdMetadata statsd_metadata = 7;
    608 
    609   // When true, the EnableTracing() request must also provide a file descriptor.
    610   // The service will then periodically read packets out of the trace buffer and
    611   // store it into the passed file.
    612   optional bool write_into_file = 8;
    613 
    614   // Optional. If non-zero tunes the write period. A min value of 100ms is
    615   // enforced (i.e. smaller values are ignored).
    616   optional uint32 file_write_period_ms = 9;
    617 
    618   // Optional. When non zero the periodic write stops once at most X bytes
    619   // have been written into the file. Tracing is disabled when this limit is
    620   // reached, even if |duration_ms| has not been reached yet.
    621   optional uint64 max_file_size_bytes = 10;
    622 
    623   // Contains flags which override the default values of the guardrails inside
    624   // Perfetto. These values are only affect userdebug builds.
    625   message GuardrailOverrides {
    626     // Override the default limit (in bytes) for uploading data to server within
    627     // a 24 hour period.
    628     optional uint64 max_upload_per_day_bytes = 1;
    629   }
    630 
    631   optional GuardrailOverrides guardrail_overrides = 11;
    632 
    633   // When true, data sources are not started until an explicit call to
    634   // StartTracing() on the consumer port. This is to support early
    635   // initialization and fast trace triggering. This can be used only when the
    636   // Consumer explicitly triggers the StartTracing() method.
    637   // This should not be used in a remote trace config via statsd, doing so will
    638   // result in a hung trace session.
    639   optional bool deferred_start = 12;
    640 
    641   // When set, it periodically issues a Flush() to all data source, forcing them
    642   // to commit their data into the tracing service. This can be used for
    643   // quasi-real-time streaming mode and to guarantee some partial ordering of
    644   // events in the trace in windows of X ms.
    645   optional uint32 flush_period_ms = 13;
    646 
    647   // Wait for this long for producers to acknowledge flush requests.
    648   // Default 5s.
    649   optional uint32 flush_timeout_ms = 14;
    650 
    651   reserved 15;  // |disable_clock_snapshotting| moved.
    652 
    653   // Android-only. If set, sends an intent to the Traceur system app when the
    654   // trace ends to notify it about the trace readiness.
    655   optional bool notify_traceur = 16;
    656 
    657   // Triggers allow producers to start or stop the tracing session when an event
    658   // occurs.
    659   //
    660   // For example if we are tracing probabilistically, most traces will be
    661   // uninteresting. Triggers allow us to keep only the interesting ones such as
    662   // those traces during which the device temperature reached a certain
    663   // threshold. In this case the producer can activate a trigger to keep
    664   // (STOP_TRACING) the trace, otherwise it can also begin a trace
    665   // (START_TRACING) because it knows something is about to happen.
    666   message TriggerConfig {
    667     enum TriggerMode {
    668       UNSPECIFIED = 0;
    669 
    670       // When this mode is chosen, data sources are not started until one of the
    671       // |triggers| are received. This supports early initialization and fast
    672       // starting of the tracing system. On triggering, the session will then
    673       // record for |stop_delay_ms|. However if no trigger is seen
    674       // after |trigger_timeout_ms| the session will be stopped and no data will
    675       // be returned.
    676       START_TRACING = 1;
    677 
    678       // When this mode is chosen, the session will be started via the normal
    679       // EnableTracing() & StartTracing(). If no trigger is ever seen
    680       // the session will be stopped after |trigger_timeout_ms| and no data will
    681       // be returned. However if triggered the trace will stop after
    682       // |stop_delay_ms| and any data in the buffer will be returned to the
    683       // consumer.
    684       STOP_TRACING = 2;
    685     }
    686     optional TriggerMode trigger_mode = 1;
    687 
    688     message Trigger {
    689       // The producer must specify this name to activate the trigger.
    690       optional string name = 1;
    691 
    692       // The a std::regex that will match the producer that can activate this
    693       // trigger. This is optional. If unset any producers can activate this
    694       // trigger.
    695       optional string producer_name_regex = 2;
    696 
    697       // After a trigger is received either in START_TRACING or STOP_TRACING
    698       // mode then the trace will end |stop_delay_ms| after triggering.
    699       optional uint32 stop_delay_ms = 3;
    700     }
    701     // A list of triggers which are related to this configuration. If ANY
    702     // trigger is seen then an action will be performed based on |trigger_mode|.
    703     repeated Trigger triggers = 2;
    704 
    705     // Required and must be positive if a TriggerConfig is specified. This is
    706     // how long this TraceConfig should wait for a trigger to arrive. After this
    707     // period of time if no trigger is seen the TracingSession will be cleaned
    708     // up.
    709     optional uint32 trigger_timeout_ms = 3;
    710   }
    711   optional TriggerConfig trigger_config = 17;
    712 
    713   // When this is non-empty the perfetto command line tool will ignore the rest
    714   // of this TraceConfig and instead connect to the perfetto service as a
    715   // producer and send these triggers, potentially stopping or starting traces
    716   // that were previous configured to use a TriggerConfig.
    717   repeated string activate_triggers = 18;
    718 
    719   // Configuration for trace contents that reference earlier trace data. For
    720   // example, a data source might intern strings, and emit packets containing
    721   // {interned id : string} pairs. Future packets from that data source can then
    722   // use the interned ids instead of duplicating the raw string contents. The
    723   // trace parser will then need to use that interning table to fully interpret
    724   // the rest of the trace.
    725   message IncrementalStateConfig {
    726     // If nonzero, notify eligible data sources to clear their incremental state
    727     // periodically, with the given period. The notification is sent only to
    728     // data sources that have |handles_incremental_state_clear| set in their
    729     // DataSourceDescriptor. The notification requests that the data source
    730     // stops referring to past trace contents. This is particularly useful when
    731     // tracing in ring buffer mode, where it is not exceptional to overwrite old
    732     // trace data.
    733     //
    734     // Warning: this time-based global clearing is likely to be removed in the
    735     // future, to be replaced with a smarter way of sending the notifications
    736     // only when necessary.
    737     optional uint32 clear_period_ms = 1;
    738   }
    739   optional IncrementalStateConfig incremental_state_config = 21;
    740 
    741   // Additional guardrail used by the Perfetto command line client.
    742   // On user builds when --dropbox is set perfetto will refuse to trace unless
    743   // this is also set.
    744   // Added in Q.
    745   optional bool allow_user_build_tracing = 19;
    746 
    747   // If set the tracing service will ensure there is at most one tracing session
    748   // with this key.
    749   optional string unique_session_name = 22;
    750 
    751   // Compress trace with the given method. Best effort.
    752   enum CompressionType {
    753     COMPRESSION_TYPE_UNSPECIFIED = 0;
    754     COMPRESSION_TYPE_DEFLATE = 1;
    755   };
    756   optional CompressionType compression_type = 24;
    757 
    758   // Android-only. Debug builds only. Not for general use. If set, saves a
    759   // Dropbox trace into an incident. This field is read by perfetto_cmd, rather
    760   // than the tracing service. All fields are mandatory.
    761   message IncidentReportConfig {
    762     optional string destination_package = 1;
    763     optional string destination_class = 2;
    764     // Level of filtering in the requested incident. See |Destination| in
    765     // frameworks/base/core/proto/android/privacy.proto.
    766     optional int32 privacy_level = 3;
    767     // If true, do not write the trace into dropbox (i.e. incident only).
    768     // Otherwise, write to both dropbox and incident.
    769     optional bool skip_dropbox = 4;
    770   }
    771   optional IncidentReportConfig incident_report_config = 25;
    772 }
    773 
    774 // End of protos/perfetto/config/trace_config.proto
    775 
    776 // Begin of protos/perfetto/config/profiling/heapprofd_config.proto
    777 
    778 // Configuration for go/heapprofd.
    779 message HeapprofdConfig {
    780   message ContinuousDumpConfig {
    781     // ms to wait before first dump.
    782     optional uint32 dump_phase_ms = 5;
    783     // ms to wait between following dumps.
    784     optional uint32 dump_interval_ms = 6;
    785   };
    786 
    787   // Set to 1 for perfect accuracy.
    788   // Otherwise, sample every sample_interval_bytes on average.
    789   //
    790   // See https://docs.perfetto.dev/#/heapprofd?id=sampling-interval for more
    791   // details.
    792   optional uint64 sampling_interval_bytes = 1;
    793 
    794   // E.g. surfaceflinger, com.android.phone
    795   // This input is normalized in the following way: if it contains slashes,
    796   // everything up to the last slash is discarded. If it contains "@",
    797   // everything after the first @ is discared.
    798   // E.g. /system/bin/surfaceflinger@1.0 normalizes to surfaceflinger.
    799   // This transformation is also applied to the processes' command lines when
    800   // matching.
    801   repeated string process_cmdline = 2;
    802 
    803   // For watermark based triggering or local debugging.
    804   repeated uint64 pid = 4;
    805 
    806   // Profile all processes eligible for profiling on the system.
    807   // See https://docs.perfetto.dev/#/heapprofd?id=target-processes for which
    808   // processes are eligible.
    809   //
    810   // On unmodified userdebug builds, this will lead to system crashes. Zygote
    811   // will crash when trying to launch a new process as it will have an
    812   // unexpected open socket to heapprofd.
    813   //
    814   // heapprofd will likely be overloaded by the amount of data for low
    815   // sampling intervals.
    816   optional bool all = 5;
    817 
    818   // Do not emit function names for mappings starting with this prefix.
    819   // E.g. /system to not emit symbols for any system libraries.
    820   repeated string skip_symbol_prefix = 7;
    821 
    822   // Dump once at the end of the trace, emitting the heap dump at maximum
    823   // memory usage.
    824   // optional bool retain_max = 5;  // TODO(fmayer): Implement
    825 
    826   // Dump at a predefined interval.
    827   optional ContinuousDumpConfig continuous_dump_config = 6;
    828 
    829   // Size of the shared memory buffer between the profiled processes and
    830   // heapprofd. Defaults to 8 MiB. If larger than 500 MiB, truncated to 500
    831   // MiB.
    832   //
    833   // Needs to be:
    834   // * at least 8192,
    835   // * a power of two,
    836   // * a multiple of 4096.
    837   optional uint64 shmem_size_bytes = 8;
    838 
    839   // When the shmem buffer is full, block the client instead of ending the
    840   // trace. Use with caution as this will significantly slow down the target
    841   // process.
    842   optional bool block_client = 9;
    843 }
    844 
    845 // End of protos/perfetto/config/profiling/heapprofd_config.proto
    846 
    847 // Begin of protos/perfetto/config/android/packages_list_config.proto
    848 
    849 // Data source that lists details (such as version code) about packages on an
    850 // Android device.
    851 message PackagesListConfig {
    852   // If not empty, emit info about only the following list of package names
    853   // (exact match, no regex). Otherwise, emit info about all packages.
    854   repeated string package_name_filter = 1;
    855 }
    856 
    857 // End of protos/perfetto/config/android/packages_list_config.proto
    858