Tracing#
Types#
Generally, you do not need to instantiate CDP types yourself. Instead, the API creates objects for you as return values from commands, and then you can use those objects as arguments to other commands.
- class MemoryDumpConfig[source]#
Configuration for memory dump. Used only when “memory-infra” category is enabled.
- class TraceConfig(record_mode=None, trace_buffer_size_in_kb=None, enable_sampling=None, enable_systrace=None, enable_argument_filter=None, included_categories=None, excluded_categories=None, synthetic_delays=None, memory_dump_config=None)[source]#
-
record_mode:
Optional[str] = None# Controls how the trace buffer stores data. The default is
recordUntilFull.
-
trace_buffer_size_in_kb:
Optional[float] = None# Size of the trace buffer in kilobytes. If not specified or zero is passed, a default value of 200 MB would be used.
-
memory_dump_config:
Optional[MemoryDumpConfig] = None# Configuration for memory dump triggers. Used only when “memory-infra” category is enabled.
-
record_mode:
- class StreamFormat(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Data format of a trace. Can be either the legacy JSON format or the protocol buffer format. Note that the JSON format will be deprecated soon.
- JSON = 'json'#
- PROTO = 'proto'#
- class StreamCompression(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Compression type to use for traces returned via streams.
- NONE = 'none'#
- GZIP = 'gzip'#
- class MemoryDumpLevelOfDetail(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Details exposed when memory request explicitly declared. Keep consistent with memory_dump_request_args.h and memory_instrumentation.mojom
- BACKGROUND = 'background'#
- LIGHT = 'light'#
- DETAILED = 'detailed'#
- class TracingBackend(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Backend type to use for tracing.
chromeuses the Chrome-integrated tracing service and is supported on all platforms.systemis only supported on Chrome OS and uses the Perfetto system tracing service.autochoosessystemwhen the perfettoConfig provided to Tracing.start specifies at least one non-Chrome data source; otherwise useschrome.- AUTO = 'auto'#
- CHROME = 'chrome'#
- SYSTEM = 'system'#
Commands#
Each command is a generator function. The return
type Generator[x, y, z] indicates that the generator
yields arguments of type x, it must be resumed with
an argument of type y, and it returns type z. In
this library, types x and y are the same for all
commands, and z is the return type you should pay attention
to. For more information, see
Getting Started: Commands.
- request_memory_dump(deterministic=None, level_of_detail=None)[source]#
Request a global memory dump.
EXPERIMENTAL
- Parameters:
deterministic (
Optional[bool]) – (Optional) Enables more deterministic results by forcing garbage collectionlevel_of_detail (
Optional[MemoryDumpLevelOfDetail]) – (Optional) Specifies level of details in memory dump. Defaults to “detailed”.
- Return type:
- Returns:
A tuple with the following items:
dumpGuid - GUID of the resulting global memory dump.
success - True iff the global memory dump succeeded.
- start(categories=None, options=None, buffer_usage_reporting_interval=None, transfer_mode=None, stream_format=None, stream_compression=None, trace_config=None, perfetto_config=None, tracing_backend=None)[source]#
Start trace events collection.
- Parameters:
categories (
Optional[str]) – (DEPRECATED) (EXPERIMENTAL) (Optional) Category/tag filteroptions (
Optional[str]) – (DEPRECATED) (EXPERIMENTAL) (Optional) Tracing optionsbuffer_usage_reporting_interval (
Optional[float]) – (EXPERIMENTAL) (Optional) If set, the agent will issue bufferUsage events at this interval, specified in millisecondstransfer_mode (
Optional[str]) – (Optional) Whether to report trace events as series of dataCollected events or to save trace to a stream (defaults to`ReportEvents``).stream_format (
Optional[StreamFormat]) – (Optional) Trace data format to use. This only applies when using``ReturnAsStream``transfer mode (defaults to``json``).stream_compression (
Optional[StreamCompression]) – (EXPERIMENTAL) (Optional) Compression format to use. This only applies when using``ReturnAsStream``transfer mode (defaults to``none``)trace_config (
Optional[TraceConfig]) – (Optional)perfetto_config (
Optional[str]) – (EXPERIMENTAL) (Optional) Base64-encoded serialized perfetto.protos.TraceConfig protobuf message When specified, the parameters``categories``,``options``,``traceConfig``are ignored. (Encoded as a base64 string when passed over JSON)tracing_backend (
Optional[TracingBackend]) – (EXPERIMENTAL) (Optional) Backend type (defaults to``auto`)
- Return type:
Events#
Generally, you do not need to instantiate CDP events yourself. Instead, the API creates events for you and then you use the event’s attributes.
- class BufferUsage(percent_full, event_count, value)[source]#
EXPERIMENTAL
- class DataCollected(value)[source]#
EXPERIMENTAL
Contains a bucket of collected trace events. When tracing is stopped collected events will be sent as a sequence of dataCollected events followed by tracingComplete event.
- class TracingComplete(data_loss_occurred, stream, trace_format, stream_compression)[source]#
Signals that tracing is stopped and there is no trace buffers pending flush, all data were delivered via dataCollected events.
-
data_loss_occurred:
bool# Indicates whether some trace data is known to have been lost, e.g. because the trace ring buffer wrapped around.
-
stream:
Optional[StreamHandle]# A handle of the stream that holds resulting trace data.
-
trace_format:
Optional[StreamFormat]# Trace data format of returned stream.
-
stream_compression:
Optional[StreamCompression]# Compression format of returned stream.
-
data_loss_occurred: