TraceAttributes


public abstract class 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 methods

abstract void
addAttribute(@NonNull String name, long value)

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

abstract void

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

abstract void

Dispatches the underlying TraceEvent to the AbstractTraceSink instance if applicable.

Public methods

addAttribute

Added in 2.0.0-alpha05
public abstract void addAttribute(@NonNull String name, long value)

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

addAttribute

Added in 2.0.0-alpha05
public abstract void addAttribute(@NonNull String name, @NonNull String value)

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

dispatchToTraceSink

Added in 2.0.0-alpha05
@DelicateTracingApi
public abstract void dispatchToTraceSink()

Dispatches the underlying TraceEvent to the AbstractTraceSink instance if applicable.