跳到主要内容

Tracing

✅️️ Methods

🔨Tracing.end

停止跟踪事件收集。

EN
Stop trace events collection.

🔨Tracing.start

开始跟踪事件收集。

EN
Start trace events collection.
参数必填标记类型描述原文
categories🧪string类别/标签过滤器
ENCategory/tag filter
options🧪string追踪选项
ENTracing options
bufferUsageReportingInterval🧪number如果设置了此项,代理将按照此间隔(以毫秒为单位)发出bufferUsage事件
ENIf set, the agent will issue bufferUsage events at this interval, specified in milliseconds
transferModestring是否将跟踪事件报告为一系列数据收集事件,还是将跟踪保存到流中(默认为ReportEvents)。
允许的值:ReportEventsReturnAsStream
ENWhether to report trace events as series of dataCollected events or to save trace to a stream (defaults to ReportEvents).
Allowed Values: ReportEvents, ReturnAsStream
streamFormatStreamFormat要使用的跟踪数据格式。这仅在使用 ReturnAsStream 传输模式时适用(默认为 json)。
ENTrace data format to use. This only applies when using ReturnAsStream transfer mode (defaults to json).
streamCompression🧪StreamCompression使用的压缩格式。这仅在使用ReturnAsStream传输模式时适用(默认为none)。
ENCompression format to use. This only applies when using ReturnAsStream transfer mode (defaults to none)
traceConfigTraceConfig
perfettoConfig🧪stringBase64编码的序列化perfetto.protos.TraceConfig protobuf消息。指定此参数时,将忽略categoriesoptionstraceConfig等参数。(通过JSON传递时需编码为base64字符串)
ENBase64-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)
tracingBackend🧪TracingBackend后端类型(默认为 auto
ENBackend type (defaults to auto)

🔨Tracing.getCategories🧪

获取支持的跟踪类别。

EN
Gets supported tracing categories.
返回对象类型描述原文
categoriesarray[string]支持的跟踪类别列表。
ENA list of supported tracing categories.

🔨Tracing.getTrackEventDescriptor🧪

返回所有可用跟踪类别的描述符。

EN
Return a descriptor for all available tracing categories.
返回对象类型描述原文
descriptorstringBase64编码的序列化perfetto.protos.TrackEventDescriptor protobuf消息。(通过JSON传递时以base64字符串形式编码)
ENBase64-encoded serialized perfetto.protos.TrackEventDescriptor protobuf message. (Encoded as a base64 string when passed over JSON)

🔨Tracing.recordClockSyncMarker🧪

在跟踪记录中记录一个时钟同步标记。

EN
Record a clock sync marker in the trace.
参数必填标记类型描述原文
syncId✔️string此时钟同步标记的ID
ENThe ID of this clock sync marker

🔨Tracing.requestMemoryDump🧪

请求一个全局内存转储。

EN
Request a global memory dump.
参数必填标记类型描述原文
deterministicboolean通过强制垃圾回收实现更确定的结果
ENEnables more deterministic results by forcing garbage collection
levelOfDetailMemoryDumpLevelOfDetail指定内存转储的详细程度。默认为 "detailed"。
ENSpecifies level of details in memory dump. Defaults to "detailed".
返回对象类型描述原文
dumpGuidstring生成的全局内存转储的GUID。
ENGUID of the resulting global memory dump.
successboolean全局内存转储成功时为真。
ENTrue iff the global memory dump succeeded.

✅️️ Events

👋Tracing.tracingComplete

发出信号表示跟踪已停止,且没有待刷新的跟踪缓冲区,所有数据已通过dataCollected事件完成传输。

EN
Signals that tracing is stopped and there is no trace buffers pending flush, all data were delivered via dataCollected events.
参数必填标记类型描述原文
dataLossOccurred✔️boolean表示是否已知某些跟踪数据已丢失,例如由于跟踪环形缓冲区环绕所致。
ENIndicates whether some trace data is known to have been lost, e.g. because the trace ring buffer wrapped around.
streamIO.StreamHandle包含结果跟踪数据的流的句柄。
ENA handle of the stream that holds resulting trace data.
traceFormatStreamFormat返回流的跟踪数据格式。
ENTrace data format of returned stream.
streamCompressionStreamCompression返回流的压缩格式。
ENCompression format of returned stream.

👋Tracing.bufferUsage🧪

参数必填标记类型描述原文
percentFullnumber一个在范围 [0..1] 内的数字,表示事件缓冲区已使用大小与其总大小的比例。
ENA number in range [0..1] that indicates the used size of event buffer as a fraction of its total size.
eventCountnumber跟踪日志中的事件近似数量。
ENAn approximate number of events in the trace log.
valuenumber一个范围在[0..1]之间的数值,表示事件缓冲区已使用大小占总容量的比例。
ENA number in range [0..1] that indicates the used size of event buffer as a fraction of its total size.

👋Tracing.dataCollected🧪

包含一系列收集到的跟踪事件。当跟踪停止时,收集到的事件将以一系列 dataCollected 事件的形式发送,随后是 tracingComplete 事件。

EN
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.
参数必填标记类型描述原文
value✔️array[object]

✅️️ Types

📌Tracing.TraceConfig

返回类型:object

属性必填标记类型描述原文
recordMode🧪string控制跟踪缓冲区如何存储数据。默认值为 recordUntilFull
允许的取值:recordUntilFullrecordContinuouslyrecordAsMuchAsPossibleechoToConsole
ENControls how the trace buffer stores data. The default is recordUntilFull.
Allowed Values: recordUntilFull, recordContinuously, recordAsMuchAsPossible, echoToConsole
traceBufferSizeInKb🧪number跟踪缓冲区的大小,以千字节为单位。如果未指定或传入零,将使用默认值200 MB。
ENSize of the trace buffer in kilobytes. If not specified or zero is passed, a default value of 200 MB would be used.
enableSampling🧪boolean启用JavaScript堆栈采样。
ENTurns on JavaScript stack sampling.
enableSystrace🧪boolean开启系统追踪功能。
ENTurns on system tracing.
enableArgumentFilter🧪boolean启用参数筛选器。
ENTurns on argument filter.
includedCategoriesarray[string]包含的类别筛选器。
ENIncluded category filters.
excludedCategoriesarray[string]排除的类别筛选器。
ENExcluded category filters.
syntheticDelays🧪array[string]配置以合成追踪中的延迟。
ENConfiguration to synthesize the delays in tracing.
memoryDumpConfig🧪MemoryDumpConfig内存转储触发器配置。仅在启用“memory-infra”类别时使用。
ENConfiguration for memory dump triggers. Used only when "memory-infra" category is enabled.

📌Tracing.MemoryDumpConfig🧪

内存转储配置。仅在启用 "memory-infra" 类别时使用。

EN
Configuration for memory dump. Used only when "memory-infra" category is enabled.

返回类型:object


📌Tracing.MemoryDumpLevelOfDetail🧪

当内存请求被明确声明时暴露的详细信息。与memory_dump_request_args.h和memory_instrumentation.mojom保持一致
允许的值:backgroundlightdetailed

EN
Details exposed when memory request explicitly declared. Keep consistent with memory_dump_request_args.h and memory_instrumentation.mojom
Allowed Values: background, light, detailed

返回类型:string


📌Tracing.StreamCompression🧪

用于通过流返回的跟踪数据的压缩类型。
允许的值:nonegzip

EN
Compression type to use for traces returned via streams.
Allowed Values: none, gzip

返回类型:string


📌Tracing.StreamFormat🧪

追踪数据格式。可以是传统的JSON格式或协议缓冲区格式。请注意,JSON格式即将被弃用。
允许值:json, proto

EN
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.
Allowed Values: json, proto

返回类型:string


📌Tracing.TracingBackend🧪

用于追踪的后端类型。chrome 使用 Chrome 集成的追踪服务,在所有平台上都受支持。system 仅在 Chrome OS 上受支持,并使用 Perfetto 系统追踪服务。auto 在提供给 Tracing.start 的 perfettoConfig 指定了至少一个非 Chrome 数据源时选择 system;否则使用 chrome
允许的值:autochromesystem

EN
Backend type to use for tracing. chrome uses the Chrome-integrated tracing service and is supported on all platforms. system is only supported on Chrome OS and uses the Perfetto system tracing service. auto chooses system when the perfettoConfig provided to Tracing.start specifies at least one non-Chrome data source; otherwise uses chrome.
Allowed Values: auto, chrome, system

返回类型:string