TraceEvent


@DelicateTracingApi
public final class TraceEvent


Mutable in-memory only representation a trace event, such as a slice start, slice end, or counter update.

This structure is optimized for performance, with the expectation that these are created by a trace event, and passed to a background thread to be serialized. Mutability (and thus reuse) is an important component of this.

Code outside of tracing-driver implementation should only ever consume these objects, not produce them.

Summary

Public fields

final @NonNull List<@NonNull AttributeEntry>

The list of trace attributes associated with the trace.

final @NonNull List<@NonNull String>

The categories that this Trace Event belongs to.

final Long

The optional correlation id associated with the event.

final String

The optional correlation id as String that is associated with the event.

final Double

Value of the trace event if the event type is TRACE_EVENT_TYPE_COUNTER.

final Long

Value of the trace event if the event type is TRACE_EVENT_TYPE_COUNTER.

final @NonNull List<@NonNull Long>

List of trace flows associated with this event.

final @NonNull List<@NonNull Frame>

A list of call stack frames that can be associated to the androidx.tracing.TraceEvent.

final int

Keeping track of the index separately for attributes, because the MutableList is pre-allocated with sentinel objects for performance reasons.

final int

Keeping track of the index separately for categories, because the MutableList is pre-allocated with sentinel objects for performance reasons.

final int

Keeping track of the index separately for frames, because the MutableList is pre-allocated with sentinel objects for performance reasons.

final int

Keeping track of the index separately, because the MutableList is pre-allocated with sentinel objects for performance reasons.

final @NonNull List<@NonNull MetadataEntry>

The list of debug annotations associated with a slice

final String

Name of the trace event - null if the event type is TRACE_EVENT_TYPE_COUNTER.

final @NonNull String

The primary category that this trace event belongs to.

final long

Timestamp in nanoseconds of the trace event.

final TrackDescriptor

If not null, this TraceEvent initializes a track, and the TrackDescriptor defines its properties.

final long

Set to the value of the containing Track's Track.uuid.

final int

Must be one of TRACE_EVENT_TYPE_UNDEFINED, TRACE_EVENT_TYPE_INSTANT, TRACE_EVENT_TYPE_BEGIN, TRACE_EVENT_TYPE_END, TRACE_EVENT_TYPE_COUNTER

Public constructors

Public methods

final void
final void

Public fields

attributes

Added in 2.0.0-rc01
public final @NonNull List<@NonNull AttributeEntryattributes

The list of trace attributes associated with the trace.

categories

Added in 2.0.0-rc01
public final @NonNull List<@NonNull Stringcategories

The categories that this Trace Event belongs to.

correlationId

Added in 2.0.0-rc01
public final Long correlationId

The optional correlation id associated with the event.

correlationIdString

Added in 2.0.0-rc01
public final String correlationIdString

The optional correlation id as String that is associated with the event.

counterDoubleValue

Added in 2.0.0-rc01
public final Double counterDoubleValue

Value of the trace event if the event type is TRACE_EVENT_TYPE_COUNTER.

Note that only one of counterDoubleValue and counterLongValue may be set.

counterLongValue

Added in 2.0.0-rc01
public final Long counterLongValue

Value of the trace event if the event type is TRACE_EVENT_TYPE_COUNTER.

Note that only one of counterDoubleValue and counterLongValue may be set.

flowIds

Added in 2.0.0-rc01
public final @NonNull List<@NonNull LongflowIds

List of trace flows associated with this event.

frames

Added in 2.0.0-rc01
public final @NonNull List<@NonNull Frameframes

A list of call stack frames that can be associated to the androidx.tracing.TraceEvent.

lastAttributeIndex

Added in 2.0.0-rc01
public final int lastAttributeIndex

Keeping track of the index separately for attributes, because the MutableList is pre-allocated with sentinel objects for performance reasons. This index can be used to determine the true size of the attributes MutableList.

lastCategoryIndex

Added in 2.0.0-rc01
public final int lastCategoryIndex

Keeping track of the index separately for categories, because the MutableList is pre-allocated with sentinel objects for performance reasons. This index can be used to determine the true size of the categories MutableList.

lastFrameIndex

Added in 2.0.0-rc01
public final int lastFrameIndex

Keeping track of the index separately for frames, because the MutableList is pre-allocated with sentinel objects for performance reasons. This index can be used to determine the true size of the frames MutableList.

lastMetadataEntryIndex

Added in 2.0.0-rc01
public final int lastMetadataEntryIndex

Keeping track of the index separately, because the MutableList is pre-allocated with sentinel objects for performance reasons. This index can be used to determine the true size of the metadataEntries MutableList.

metadataEntries

Added in 2.0.0-rc01
public final @NonNull List<@NonNull MetadataEntrymetadataEntries

The list of debug annotations associated with a slice

name

Added in 2.0.0-rc01
public final String name

Name of the trace event - null if the event type is TRACE_EVENT_TYPE_COUNTER.

primaryCategory

Added in 2.0.0-rc01
public final @NonNull String primaryCategory

The primary category that this trace event belongs to.

timestamp

Added in 2.0.0-rc01
public final long timestamp

Timestamp in nanoseconds of the trace event.

trackDescriptor

Added in 2.0.0-rc01
public final TrackDescriptor trackDescriptor

If not null, this TraceEvent initializes a track, and the TrackDescriptor defines its properties.

trackUuid

Added in 2.0.0-rc01
public final long trackUuid

Set to the value of the containing Track's Track.uuid.

Public constructors

TraceEvent

Added in 2.0.0-rc01
public TraceEvent()

Public methods

copyFrom

Added in 2.0.0-rc01
public final void copyFrom(@NonNull TraceEvent src)

reset

Added in 2.0.0-rc01
public final void reset()