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.py
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: 8.
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      RING_BUFFER = 1;
43      // TODO: not implemented yet.
44      // STOP_WHEN_FULL = 2;
45    }
46    optional FillPolicy fill_policy = 4;
47  }
48  repeated BufferConfig buffers = 1;
49
50  message DataSource {
51    // Filters and data-source specific config. It contains also the unique name
52    // of the data source, the one passed in the  DataSourceDescriptor when they
53    // register on the service.
54    optional protos.DataSourceConfig config = 1;
55
56    // Optional. If multiple producers (~processes) expose the same data source
57    // and |producer_name_filter| != "", the data source is enabled only for
58    // producers whose names match any of the producer_name_filter below.
59    // The |producer_name_filter| has to be an exact match. (TODO(primiano):
60    // support wildcards or regex).
61    // This allows to enable a data source only for specific processes.
62    // The "repeated" field has OR sematics: specifying a filter ["foo", "bar"]
63    // will enable data source on both "foo" and "bar" (if existent).
64    repeated string producer_name_filter = 2;
65  }
66  repeated DataSource data_sources = 2;
67
68  optional uint32 duration_ms = 3;
69
70  // This is set when --dropbox is passed to the Perfetto command line client
71  // and enables guardrails that limit resource usage for traces requested
72  // by statsd.
73  optional bool enable_extra_guardrails = 4;
74
75  enum LockdownModeOperation {
76    LOCKDOWN_UNCHANGED = 0;
77    LOCKDOWN_CLEAR = 1;
78    LOCKDOWN_SET = 2;
79  }
80  // Reject producers that are not running under the same UID as the tracing
81  // service.
82  optional LockdownModeOperation lockdown_mode = 5;
83
84  message ProducerConfig {
85    // Identifies the producer for which this config is for.
86    optional string producer_name = 1;
87
88    // Specifies the preferred size of the shared memory buffer. If the size is
89    // larger than the max size, the max will be used. If it is smaller than
90    // the page size or doesn't fit pages evenly into it, it will fall back to
91    // the size specified by the producer or finally the default shared memory
92    // size.
93    optional uint32 shm_size_kb = 2;
94
95    // Specifies the preferred size of each page in the shared memory buffer.
96    // Must be an integer mutiple of 4K.
97    optional uint32 page_size_kb = 3;
98  }
99
100  repeated ProducerConfig producers = 6;
101
102  // Contains statsd-specific metadata about an alert associated with the trace.
103  message StatsdMetadata {
104    // The identifier of the alert which triggered this trace.
105    optional int64 triggering_alert_id = 1;
106    // The uid which registered the triggering configuration with statsd.
107    optional int32 triggering_config_uid = 2;
108    // The identifier of the config which triggered the alert.
109    optional int64 triggering_config_id = 3;
110  }
111
112  // Statsd-specific metadata.
113  optional StatsdMetadata statsd_metadata = 7;
114
115  // When true, the EnableTracing() request must also provide a file descriptor.
116  // The service will then periodically read packets out of the trace buffer and
117  // store it into the passed file.
118  optional bool write_into_file = 8;
119
120  // Optional. If non-zero tunes the write period. A min value of 100ms is
121  // enforced (i.e. smaller values are ignored).
122  optional uint32 file_write_period_ms = 9;
123
124  // Optional. When non zero the periodic write stops once at most X bytes
125  // have been written into the file. Tracing is disabled when this limit is
126  // reached, even if |duration_ms| has not been reached yet.
127  optional uint64 max_file_size_bytes = 10;
128
129  // Contains flags which override the default values of the guardrails inside
130  // Perfetto. These values are only affect userdebug builds.
131  message GuardrailOverrides {
132    // Override the default limit (in bytes) for uploading data to server within
133    // a 24 hour period.
134    optional uint64 max_upload_per_day_bytes = 1;
135  }
136
137  optional GuardrailOverrides guardrail_overrides = 11;
138}
139