Skip to main content

cdp_driver/protocol/
tracing.rs

1// @generated by `just generate-methods` from protocol/*.json.
2// Do not edit by hand; edit xtask/ and regenerate.
3
4//! The `Tracing` domain.
5//!
6//! Types, command parameters and event payloads for the `Tracing`
7//! domain. The method-name constants for the same domain are in
8//! [`crate::methods`].
9
10use serde::{Deserialize, Serialize};
11
12/// Configuration for memory dump. Used only when "memory-infra" category is
13/// enabled.
14///
15/// Experimental: may change without notice.
16pub type MemoryDumpConfig = serde_json::Value;
17
18#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
19pub struct TraceConfig {
20    /// Controls how the trace buffer stores data. The default is
21    /// `recordUntilFull`.
22    ///
23    /// Experimental: may change without notice.
24    #[serde(
25        rename = "recordMode",
26        default,
27        skip_serializing_if = "Option::is_none"
28    )]
29    pub record_mode: Option<TraceConfigRecordMode>,
30    /// Size of the trace buffer in kilobytes. If not specified or zero is passed,
31    /// a default value of 200 MB would be used.
32    ///
33    /// Experimental: may change without notice.
34    #[serde(
35        rename = "traceBufferSizeInKb",
36        default,
37        skip_serializing_if = "Option::is_none"
38    )]
39    pub trace_buffer_size_in_kb: Option<f64>,
40    /// Turns on JavaScript stack sampling.
41    ///
42    /// Experimental: may change without notice.
43    #[serde(
44        rename = "enableSampling",
45        default,
46        skip_serializing_if = "Option::is_none"
47    )]
48    pub enable_sampling: Option<bool>,
49    /// Turns on system tracing.
50    ///
51    /// Experimental: may change without notice.
52    #[serde(
53        rename = "enableSystrace",
54        default,
55        skip_serializing_if = "Option::is_none"
56    )]
57    pub enable_systrace: Option<bool>,
58    /// Turns on argument filter.
59    ///
60    /// Experimental: may change without notice.
61    #[serde(
62        rename = "enableArgumentFilter",
63        default,
64        skip_serializing_if = "Option::is_none"
65    )]
66    pub enable_argument_filter: Option<bool>,
67    /// Included category filters.
68    #[serde(
69        rename = "includedCategories",
70        default,
71        skip_serializing_if = "Option::is_none"
72    )]
73    pub included_categories: Option<Vec<String>>,
74    /// Excluded category filters.
75    #[serde(
76        rename = "excludedCategories",
77        default,
78        skip_serializing_if = "Option::is_none"
79    )]
80    pub excluded_categories: Option<Vec<String>>,
81    /// Configuration to synthesize the delays in tracing.
82    ///
83    /// Experimental: may change without notice.
84    #[serde(
85        rename = "syntheticDelays",
86        default,
87        skip_serializing_if = "Option::is_none"
88    )]
89    pub synthetic_delays: Option<Vec<String>>,
90    /// Configuration for memory dump triggers. Used only when "memory-infra"
91    /// category is enabled.
92    ///
93    /// Experimental: may change without notice.
94    #[serde(
95        rename = "memoryDumpConfig",
96        default,
97        skip_serializing_if = "Option::is_none"
98    )]
99    pub memory_dump_config: Option<MemoryDumpConfig>,
100}
101
102/// The values `recordMode` accepts on `TraceConfig`.
103#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
104pub enum TraceConfigRecordMode {
105    /// `recordUntilFull`
106    #[serde(rename = "recordUntilFull")]
107    RecordUntilFull,
108    /// `recordContinuously`
109    #[serde(rename = "recordContinuously")]
110    RecordContinuously,
111    /// `recordAsMuchAsPossible`
112    #[serde(rename = "recordAsMuchAsPossible")]
113    RecordAsMuchAsPossible,
114    /// `echoToConsole`
115    #[serde(rename = "echoToConsole")]
116    EchoToConsole,
117    /// A value this vendored schema does not list. Chrome adds values ahead of
118    /// the published protocol, so an unrecognised one is kept as it arrived
119    /// rather than failing the payload it came in.
120    #[serde(untagged)]
121    Unrecognized(String),
122}
123
124/// Data format of a trace. Can be either the legacy JSON format or the
125/// protocol buffer format. Note that the JSON format will be deprecated soon.
126///
127/// Experimental: may change without notice.
128#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
129pub enum StreamFormat {
130    /// `json`
131    #[serde(rename = "json")]
132    Json,
133    /// `proto`
134    #[serde(rename = "proto")]
135    Proto,
136    /// A value this vendored schema does not list. Chrome adds values ahead of
137    /// the published protocol, so an unrecognised one is kept as it arrived
138    /// rather than failing the payload it came in.
139    #[serde(untagged)]
140    Unrecognized(String),
141}
142
143/// Compression type to use for traces returned via streams.
144///
145/// Experimental: may change without notice.
146#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
147pub enum StreamCompression {
148    /// `none`
149    #[serde(rename = "none")]
150    None,
151    /// `gzip`
152    #[serde(rename = "gzip")]
153    Gzip,
154    /// A value this vendored schema does not list. Chrome adds values ahead of
155    /// the published protocol, so an unrecognised one is kept as it arrived
156    /// rather than failing the payload it came in.
157    #[serde(untagged)]
158    Unrecognized(String),
159}
160
161/// Details exposed when memory request explicitly declared. Keep consistent
162/// with memory_dump_request_args.h and memory_instrumentation.mojom
163///
164/// Experimental: may change without notice.
165#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
166pub enum MemoryDumpLevelOfDetail {
167    /// `background`
168    #[serde(rename = "background")]
169    Background,
170    /// `light`
171    #[serde(rename = "light")]
172    Light,
173    /// `detailed`
174    #[serde(rename = "detailed")]
175    Detailed,
176    /// A value this vendored schema does not list. Chrome adds values ahead of
177    /// the published protocol, so an unrecognised one is kept as it arrived
178    /// rather than failing the payload it came in.
179    #[serde(untagged)]
180    Unrecognized(String),
181}
182
183/// Backend type to use for tracing. `chrome` uses the Chrome-integrated
184/// tracing service and is supported on all platforms. `system` is only
185/// supported on Chrome OS and uses the Perfetto system tracing service.
186/// `auto` chooses `system` when the perfettoConfig provided to Tracing.start
187/// specifies at least one non-Chrome data source; otherwise uses `chrome`.
188///
189/// Experimental: may change without notice.
190#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
191pub enum TracingBackend {
192    /// `auto`
193    #[serde(rename = "auto")]
194    Auto,
195    /// `chrome`
196    #[serde(rename = "chrome")]
197    Chrome,
198    /// `system`
199    #[serde(rename = "system")]
200    System,
201    /// A value this vendored schema does not list. Chrome adds values ahead of
202    /// the published protocol, so an unrecognised one is kept as it arrived
203    /// rather than failing the payload it came in.
204    #[serde(untagged)]
205    Unrecognized(String),
206}
207
208/// Stop trace events collection.
209///
210/// Parameters of `Tracing.end`.
211#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
212pub struct EndParams {}
213
214impl crate::typed::Command for EndParams {
215    const METHOD: &'static str = "Tracing.end";
216    type Returns = crate::typed::NoReturns;
217}
218
219/// Gets supported tracing categories.
220///
221/// Experimental: may change without notice.
222///
223/// Parameters of `Tracing.getCategories`.
224#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
225pub struct GetCategoriesParams {}
226
227/// What `Tracing.getCategories` answers with.
228#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
229pub struct GetCategoriesReturns {
230    /// A list of supported tracing categories.
231    pub categories: Vec<String>,
232}
233
234impl crate::typed::Command for GetCategoriesParams {
235    const METHOD: &'static str = "Tracing.getCategories";
236    type Returns = GetCategoriesReturns;
237}
238
239/// Return a descriptor for all available tracing categories.
240///
241/// Experimental: may change without notice.
242///
243/// Parameters of `Tracing.getTrackEventDescriptor`.
244#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
245pub struct GetTrackEventDescriptorParams {}
246
247/// What `Tracing.getTrackEventDescriptor` answers with.
248#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
249pub struct GetTrackEventDescriptorReturns {
250    /// Base64-encoded serialized perfetto.protos.TrackEventDescriptor protobuf
251    /// message. (Encoded as a base64 string when passed over JSON)
252    pub descriptor: String,
253}
254
255impl crate::typed::Command for GetTrackEventDescriptorParams {
256    const METHOD: &'static str = "Tracing.getTrackEventDescriptor";
257    type Returns = GetTrackEventDescriptorReturns;
258}
259
260/// Record a clock sync marker in the trace.
261///
262/// Experimental: may change without notice.
263///
264/// Parameters of `Tracing.recordClockSyncMarker`.
265#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
266pub struct RecordClockSyncMarkerParams {
267    /// The ID of this clock sync marker
268    #[serde(rename = "syncId")]
269    pub sync_id: String,
270}
271
272impl crate::typed::Command for RecordClockSyncMarkerParams {
273    const METHOD: &'static str = "Tracing.recordClockSyncMarker";
274    type Returns = crate::typed::NoReturns;
275}
276
277/// Request a global memory dump.
278///
279/// Experimental: may change without notice.
280///
281/// Parameters of `Tracing.requestMemoryDump`.
282#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
283pub struct RequestMemoryDumpParams {
284    /// Enables more deterministic results by forcing garbage collection
285    #[serde(default, skip_serializing_if = "Option::is_none")]
286    pub deterministic: Option<bool>,
287    /// Specifies level of details in memory dump. Defaults to "detailed".
288    #[serde(
289        rename = "levelOfDetail",
290        default,
291        skip_serializing_if = "Option::is_none"
292    )]
293    pub level_of_detail: Option<MemoryDumpLevelOfDetail>,
294}
295
296/// What `Tracing.requestMemoryDump` answers with.
297#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
298pub struct RequestMemoryDumpReturns {
299    /// GUID of the resulting global memory dump.
300    #[serde(rename = "dumpGuid")]
301    pub dump_guid: String,
302    /// True iff the global memory dump succeeded.
303    pub success: bool,
304}
305
306impl crate::typed::Command for RequestMemoryDumpParams {
307    const METHOD: &'static str = "Tracing.requestMemoryDump";
308    type Returns = RequestMemoryDumpReturns;
309}
310
311/// Start trace events collection.
312///
313/// Parameters of `Tracing.start`.
314#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
315pub struct StartParams {
316    /// Category/tag filter
317    ///
318    /// Deprecated in the protocol.
319    ///
320    /// Experimental: may change without notice.
321    #[serde(default, skip_serializing_if = "Option::is_none")]
322    pub categories: Option<String>,
323    /// Tracing options
324    ///
325    /// Deprecated in the protocol.
326    ///
327    /// Experimental: may change without notice.
328    #[serde(default, skip_serializing_if = "Option::is_none")]
329    pub options: Option<String>,
330    /// If set, the agent will issue bufferUsage events at this interval,
331    /// specified in milliseconds
332    ///
333    /// Experimental: may change without notice.
334    #[serde(
335        rename = "bufferUsageReportingInterval",
336        default,
337        skip_serializing_if = "Option::is_none"
338    )]
339    pub buffer_usage_reporting_interval: Option<f64>,
340    /// Whether to report trace events as series of dataCollected events or to
341    /// save trace to a stream (defaults to `ReportEvents`).
342    #[serde(
343        rename = "transferMode",
344        default,
345        skip_serializing_if = "Option::is_none"
346    )]
347    pub transfer_mode: Option<StartTransferMode>,
348    /// Trace data format to use. This only applies when using `ReturnAsStream`
349    /// transfer mode (defaults to `json`).
350    #[serde(
351        rename = "streamFormat",
352        default,
353        skip_serializing_if = "Option::is_none"
354    )]
355    pub stream_format: Option<StreamFormat>,
356    /// Compression format to use. This only applies when using `ReturnAsStream`
357    /// transfer mode (defaults to `none`)
358    ///
359    /// Experimental: may change without notice.
360    #[serde(
361        rename = "streamCompression",
362        default,
363        skip_serializing_if = "Option::is_none"
364    )]
365    pub stream_compression: Option<StreamCompression>,
366    #[serde(
367        rename = "traceConfig",
368        default,
369        skip_serializing_if = "Option::is_none"
370    )]
371    pub trace_config: Option<TraceConfig>,
372    /// Base64-encoded serialized perfetto.protos.TraceConfig protobuf message
373    /// When specified, the parameters `categories`, `options`, `traceConfig` are
374    /// ignored. (Encoded as a base64 string when passed over JSON)
375    ///
376    /// Experimental: may change without notice.
377    #[serde(
378        rename = "perfettoConfig",
379        default,
380        skip_serializing_if = "Option::is_none"
381    )]
382    pub perfetto_config: Option<String>,
383    /// Backend type (defaults to `auto`)
384    ///
385    /// Experimental: may change without notice.
386    #[serde(
387        rename = "tracingBackend",
388        default,
389        skip_serializing_if = "Option::is_none"
390    )]
391    pub tracing_backend: Option<TracingBackend>,
392    /// Maximum width and height (in pixels) of each captured screenshot. Only
393    /// used when the `disabled-by-default-devtools.screenshot` category is
394    /// enabled. Defaults to 500. The combined memory footprint of screenshots
395    /// (`screenshotMaxSize` * `screenshotMaxSize` * 4 * `screenshotMaxCount`) is
396    /// clamped to the existing per-session budget.
397    ///
398    /// Experimental: may change without notice.
399    #[serde(
400        rename = "screenshotMaxSize",
401        default,
402        skip_serializing_if = "Option::is_none"
403    )]
404    pub screenshot_max_size: Option<i64>,
405    /// Maximum number of screenshots captured during a single tracing session.
406    /// Only used when the `disabled-by-default-devtools.screenshot` category is
407    /// enabled. Defaults to 450. Clamped together with `screenshotMaxSize` to
408    /// stay within the per-session screenshot memory budget.
409    ///
410    /// Experimental: may change without notice.
411    #[serde(
412        rename = "screenshotMaxCount",
413        default,
414        skip_serializing_if = "Option::is_none"
415    )]
416    pub screenshot_max_count: Option<i64>,
417}
418
419/// The values `transferMode` accepts on `start`.
420#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
421pub enum StartTransferMode {
422    /// `ReportEvents`
423    ReportEvents,
424    /// `ReturnAsStream`
425    ReturnAsStream,
426    /// A value this vendored schema does not list. Chrome adds values ahead of
427    /// the published protocol, so an unrecognised one is kept as it arrived
428    /// rather than failing the payload it came in.
429    #[serde(untagged)]
430    Unrecognized(String),
431}
432
433impl crate::typed::Command for StartParams {
434    const METHOD: &'static str = "Tracing.start";
435    type Returns = crate::typed::NoReturns;
436}
437
438/// Experimental: may change without notice.
439///
440/// Payload of the `Tracing.bufferUsage` event.
441#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
442pub struct BufferUsageEvent {
443    /// A number in range \[0..1\] that indicates the used size of event buffer as
444    /// a fraction of its total size.
445    #[serde(
446        rename = "percentFull",
447        default,
448        skip_serializing_if = "Option::is_none"
449    )]
450    pub percent_full: Option<f64>,
451    /// An approximate number of events in the trace log.
452    #[serde(
453        rename = "eventCount",
454        default,
455        skip_serializing_if = "Option::is_none"
456    )]
457    pub event_count: Option<f64>,
458    /// A number in range \[0..1\] that indicates the used size of event buffer as
459    /// a fraction of its total size.
460    #[serde(default, skip_serializing_if = "Option::is_none")]
461    pub value: Option<f64>,
462}
463
464impl crate::typed::Event for BufferUsageEvent {
465    const METHOD: &'static str = "Tracing.bufferUsage";
466}
467
468/// Contains a bucket of collected trace events. When tracing is stopped
469/// collected events will be sent as a sequence of dataCollected events
470/// followed by tracingComplete event.
471///
472/// Experimental: may change without notice.
473///
474/// Payload of the `Tracing.dataCollected` event.
475#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
476pub struct DataCollectedEvent {
477    pub value: Vec<serde_json::Value>,
478}
479
480impl crate::typed::Event for DataCollectedEvent {
481    const METHOD: &'static str = "Tracing.dataCollected";
482}
483
484/// Signals that tracing is stopped and there is no trace buffers pending
485/// flush, all data were delivered via dataCollected events.
486///
487/// Payload of the `Tracing.tracingComplete` event.
488#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
489pub struct TracingCompleteEvent {
490    /// Indicates whether some trace data is known to have been lost, e.g. because
491    /// the trace ring buffer wrapped around.
492    #[serde(rename = "dataLossOccurred")]
493    pub data_loss_occurred: bool,
494    /// A handle of the stream that holds resulting trace data.
495    #[serde(default, skip_serializing_if = "Option::is_none")]
496    pub stream: Option<crate::protocol::io::StreamHandle>,
497    /// Trace data format of returned stream.
498    #[serde(
499        rename = "traceFormat",
500        default,
501        skip_serializing_if = "Option::is_none"
502    )]
503    pub trace_format: Option<StreamFormat>,
504    /// Compression format of returned stream.
505    #[serde(
506        rename = "streamCompression",
507        default,
508        skip_serializing_if = "Option::is_none"
509    )]
510    pub stream_compression: Option<StreamCompression>,
511}
512
513impl crate::typed::Event for TracingCompleteEvent {
514    const METHOD: &'static str = "Tracing.tracingComplete";
515}