androidx.tracing


Classes

Trace

Writes trace events to the system trace buffer.

Top-level functions summary

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.

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.

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.

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.

Top-level functions

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.

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.

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