androidx.tracing


Interfaces

PropagationToken

A token representing state carried forward for context propagation.

Cmn

Classes

AtomicBoolean
Cmn
android
AtomicInteger
Cmn
android
AtomicLong
Cmn
android
Counter

Useful to emit counters into a Trace.

Cmn
EventMetadata

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

Cmn
EventMetadataCloseable

A holder for a EventMetadata and the AutoCloseable.

Cmn
Frame

TraceEvents can additionally contain callstack information.

Cmn
MetadataEntry

TraceEvents can contain metadata.

Cmn
PlatformThreadContextElement

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

Cmn
Poolable

Represents an object that can be reused using a Pool.

Cmn
PooledTracePacketArray
Cmn
TraceDriver

The entry point for the tracing API.

Cmn
TraceEvent

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

Cmn
TraceSink

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

Cmn
Tracer

A Tracer is the entry point for all Tracing APIs.

Cmn
TrackDescriptor

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

Cmn

Objects

PropagationUnsupportedToken

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

Cmn
Trace
Cmn
android

Annotations

DelicateTracingApi

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

Cmn
ExperimentalContextPropagation

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

Cmn

Type aliases

AtomicBoolean
android
AtomicInteger
android
AtomicLong
android

Top-level functions summary

Long
Cmn
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

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.