androidx.tracing


Interfaces

AbstractTraceDriver.Factory

Provides the instance of AbstractTraceDriver that can be used for in-process-tracing.

android
Counter

Handle for emitting Long or Counter counter event updates into a trace.

android
PropagationToken

A token representing state carried forward for context propagation.

android

Classes

AbstractTraceDriver

The entry point for the tracing API.

android
AbstractTraceSink

Receives PooledTracePacketArrays from Tracks and asynchronously serializes them to a file or buffer, depending on implementation.

android
AtomicBoolean
android
AtomicInteger
android
AtomicLong
android
AttributeEntry

TraceEvents can contain trace attributes that apply to the entire trace.

android
EventMetadata

Makes it possible to associate debug metadata & categories to a TraceEvent.

android
EventMetadataCloseable

A holder for a EventMetadata and the AutoCloseable.

android
Frame

TraceEvents can additionally contain callstack information.

android
MetadataEntry

TraceEvents can contain metadata.

android
PlatformThreadContextElement

We use the PlatformThreadContextElement construct to know when a coroutine has suspended, and about to resume on a Thread.

android
Poolable

Represents an object that can be reused using a Pool.

android
PooledTracePacketArray
android
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.

android
TraceEvent

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

android
Tracer

A Tracer is the entry point for all Tracing APIs.

android
TrackDescriptor

Low level representation of a Track, written once to the Trace.

android

Objects

PropagationUnsupportedToken

The PropagationToken instance that should be returned when context propagation is unsupported by the underlying Tracer.

android
Trace
android

Annotations

DelicateTracingApi

Represents an API surface that is typically only useful for custom implementations of a AbstractTraceSink or a Track.

android
ExperimentalContextPropagation

Represents an API surface that is typically only useful for custom context propagation.

android

Type aliases

AtomicBoolean
android
AtomicInteger
android
AtomicLong
android

Top-level functions summary

Long
android
inline T
<T : Any?> trace(label: String, block: () -> T)

Wrap the specified block in calls to Trace.beginSection (with the supplied label) and Trace.endSection.

android
inline T
<T : Any?> trace(lazyLabel: () -> String, block: () -> T)

Wrap the specified block in calls to Trace.beginSection (with a lazy-computed lazyLabel, only if tracing is enabled - Trace.isEnabled) and Trace.endSection.

android
inline T
<T : Any?> traceAsync(
    lazyMethodName: () -> String,
    lazyCookie: () -> Int,
    block: () -> T
)

Wrap the specified block in calls to Trace.beginAsyncSection and Trace.endAsyncSection, with a lazy-computed lazyMethodName and lazyCookie, only if tracing is enabled - Trace.isEnabled.

android
suspend inline T
<T : Any?> traceAsync(
    methodName: String,
    cookie: Int,
    crossinline block: suspend () -> T
)

Wrap the specified block in calls to Trace.beginAsyncSection (with the supplied methodName and cookie) and Trace.endAsyncSection.

android

Extension functions summary

Nothing
Tracer.recordExceptionAndThrow(
    category: String,
    name: String,
    throwable: Throwable
)

Records an exceptional event in a trace.

android

Top-level functions

nanoTime

fun nanoTime(): Long

trace

inline fun <T : Any?> trace(label: String, block: () -> T): T

Wrap the specified block in calls to Trace.beginSection (with the supplied label) and Trace.endSection.

Parameters
label: String

A name of the code section to appear in the trace.

block: () -> T

A block of code which is being traced.

trace

inline fun <T : Any?> trace(lazyLabel: () -> String, block: () -> T): T

Wrap the specified block in calls to Trace.beginSection (with a lazy-computed lazyLabel, only if tracing is enabled - Trace.isEnabled) and Trace.endSection.

This variant allows you to build a dynamic label, but only when tracing is enabled, avoiding the cost of String construction otherwise.

Parameters
lazyLabel: () -> String

A name of the code section to appear in the trace, computed lazily if needed.

block: () -> T

A block of code which is being traced.

traceAsync

inline fun <T : Any?> traceAsync(
    lazyMethodName: () -> String,
    lazyCookie: () -> Int,
    block: () -> T
): T

Wrap the specified block in calls to Trace.beginAsyncSection and Trace.endAsyncSection, with a lazy-computed lazyMethodName and lazyCookie, only if tracing is enabled - Trace.isEnabled.

Parameters
lazyMethodName: () -> String

The method name to appear in the trace, computed lazily if needed.

lazyCookie: () -> Int

Unique identifier for distinguishing simultaneous events, computed lazily if needed.

block: () -> T

a code block to be wrapped between Trace.beginAsyncSection and Trace.endAsyncSection.

traceAsync

suspend inline fun <T : Any?> traceAsync(
    methodName: String,
    cookie: Int,
    crossinline block: suspend () -> T
): T

Wrap the specified block in calls to Trace.beginAsyncSection (with the supplied methodName and cookie) and Trace.endAsyncSection.

Parameters
methodName: String

The method name to appear in the trace.

cookie: Int

Unique identifier for distinguishing simultaneous events

crossinline block: suspend () -> T

A code block to be wrapped between Trace.beginAsyncSection and Trace.endAsyncSection.

Extension functions

Tracer.recordExceptionAndThrow

fun Tracer.recordExceptionAndThrow(
    category: String,
    name: String,
    throwable: Throwable
): Nothing

Records an exceptional event in a trace. This method rethrows the throwable after having extracting all metadata worth tracing.

Parameters
category: String

The String category. It's useful to categorize TraceEvents, so that they can be filtered if necessary using the appropriate trace configuration.

name: String

The name of the trace section.

throwable: Throwable

The exception thrown by a block of code.