TraceKt

Added in 1.0.0

public final class TraceKt


Summary

Public methods

static final @NonNull T
<T extends Object> trace(@NonNull String label, @NonNull Function0<@NonNull T> block)

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

static final @NonNull T
<T extends Object> trace(
    @NonNull Function0<@NonNull String> lazyLabel,
    @NonNull Function0<@NonNull T> block
)

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

static final @NonNull T
<T extends Object> traceAsync(
    @NonNull Function0<@NonNull String> lazyMethodName,
    @NonNull Function0<@NonNull Integer> lazyCookie,
    @NonNull Function0<@NonNull T> block
)

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.

static final @NonNull T
<T extends Object> traceAsync(
    @NonNull String methodName,
    int cookie,
    @NonNull SuspendFunction0<@NonNull T> block
)

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

Public methods

public static final @NonNull T <T extends Object> trace(@NonNull String label, @NonNull Function0<@NonNull T> block)

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

Parameters
@NonNull String label

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

@NonNull Function0<@NonNull T> block

A block of code which is being traced.

public static final @NonNull T <T extends Object> trace(
    @NonNull Function0<@NonNull String> lazyLabel,
    @NonNull Function0<@NonNull T> block
)

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
@NonNull Function0<@NonNull String> lazyLabel

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

@NonNull Function0<@NonNull T> block

A block of code which is being traced.

traceAsync

public static final @NonNull T <T extends Object> traceAsync(
    @NonNull Function0<@NonNull String> lazyMethodName,
    @NonNull Function0<@NonNull Integer> lazyCookie,
    @NonNull Function0<@NonNull T> block
)

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
@NonNull Function0<@NonNull String> lazyMethodName

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

@NonNull Function0<@NonNull Integer> lazyCookie

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

public static final @NonNull T <T extends Object> traceAsync(
    @NonNull String methodName,
    int cookie,
    @NonNull SuspendFunction0<@NonNull T> block
)

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

Parameters
@NonNull String methodName

The method name to appear in the trace.

int cookie

Unique identifier for distinguishing simultaneous events