TraceAttributes



Makes it possible to associate key value pairs to be attached to a trace to provide additional context about any facet of the trace. This can include what data it contains, and properties of the host / machine the trace was collected on, and other interesting information about a trace.

Examples include:

gradle_version = "9.0.10-alpha01"
java_major_version = 24

All keys get prefixed with trace_attribute. in Perfetto UI and in traceprocessor. If there are multiple trace attributes that use the same key then the last value wins.

These key value pairs show up in the Overview section in Perfetto UI. Additionally, these key, value pairs can be queried using Perfetto SQL using the following query:

SELECT * FROM metadata WHERE name GLOB 'trace_attribute.*';

Summary

Public functions

abstract Unit
addAttribute(name: String, value: Long)

Adds a trace attribute entry where the type of the value is a Long.

Cmn
abstract Unit
addAttribute(name: String, value: String)

Adds a trace attribute entry where the type of the value is a String.

Cmn
abstract Unit

Dispatches the underlying TraceEvent to the AbstractTraceSink instance if applicable.

Cmn

Public functions

addAttribute

abstract fun addAttribute(name: String, value: Long): Unit

Adds a trace attribute entry where the type of the value is a Long.

addAttribute

abstract fun addAttribute(name: String, value: String): Unit

Adds a trace attribute entry where the type of the value is a String.

dispatchToTraceSink

@DelicateTracingApi
abstract fun dispatchToTraceSink(): Unit

Dispatches the underlying TraceEvent to the AbstractTraceSink instance if applicable.