Tracer.Companion


public static class Tracer.Companion


Summary

Public methods

static final @NonNull Tracer

The Global tracer configured by the application.

static final @NonNull Tracer
static final void

Resets the global for JVM and Android tests.

static final void

Registers the global Tracer instance.

Public methods

getGlobal

Added in 2.0.0-alpha09
public static final @NonNull Tracer getGlobal()

The Global tracer configured by the application.

This is the Tracer that should be used by both application and library developers. You should always use Tracer.global and not cache references this field, given the Tracer being used, is updated after the application is initialized.

The global tracer is typically bootstrapped during process startup. When using androidx.tracing:tracing-wire, androidx.tracing.profiler.ConnectedProfilerTracingInitializer discovers the AbstractTraceDriver.Factory, and constructs the instance. It then registers a global Tracer by calling Tracer.setGlobalTracer.

Otherwise, construct AbstractTraceDriver during startup and register it via Tracer.setGlobalTracer so other components can discover and use it.

getStubTracer

Added in 2.0.0-alpha09
@<error>
public static final @NonNull Tracer getStubTracer()
Returns
@NonNull Tracer

a Tracer instance that is a stub (does nothing). This is useful as a placeholder when you want to enable / disable tracing for the program.

resetGlobalTracer

Added in 2.0.0-alpha09
@VisibleForTesting
public static final void resetGlobalTracer()

Resets the global for JVM and Android tests.

Note: This API should only be used in tests.

setGlobalTracer

Added in 2.0.0-alpha09
@<error>
@DelicateTracingApi
public static final void setGlobalTracer(@NonNull Tracer tracer)

Registers the global Tracer instance.

This should only ever be done once per process lifecycle and by the application initializing the AbstractTraceDriver; typically during app startup.

This should never be called by libraries.