AbstractTraceSink


public abstract class AbstractTraceSink implements AutoCloseable

Known direct subclasses
InMemoryRingBufferTraceSink

A AbstractTraceSink that stores TraceEvents in a fixed-size ring buffer to minimize allocations.

TraceSink

The trace sink that writes BufferedSink, to a new file per trace session.


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

Note that while serialized trace events are typically written as Perfetto TracePacket protos so that they may be read by ui.perfetto.dev and queried with the corresponding TraceProcessor tools, the final serialization format is up to the AbstractTraceSink's implementation.

Summary

Public constructors

Public methods

abstract void

Close the AbstractTraceSink, completing any enqueued writes.

abstract void

Enqueue a PooledTracePacketArray to be written to the trace.

abstract void

Flush any enqueued trace events to the AbstractTraceSink.

abstract void

Called when the AbstractTraceSink cannot keep up with incoming trace events from Tracks.

Public constructors

AbstractTraceSink

Added in 2.0.0-alpha04
public AbstractTraceSink()

Public methods

close

Added in 2.0.0-alpha04
public abstract void close()

Close the AbstractTraceSink, completing any enqueued writes.

This function may be called from any thread.

enqueue

Added in 2.0.0-alpha04
public abstract void enqueue(@NonNull PooledTracePacketArray pooledPacketArray)

Enqueue a PooledTracePacketArray to be written to the trace.

This function may be called from any thread.

flush

Added in 2.0.0-alpha04
public abstract void flush()

Flush any enqueued trace events to the AbstractTraceSink.

If the trace sink writes to persistent storage, this forces any buffered events to be written immediately. For in-memory sinks, this is typically a no-op because they do not have an underlying persistent storage destination by default.

This function may be called from any thread.

onDroppedTraceEvent

Added in 2.0.0-alpha04
public abstract void onDroppedTraceEvent()

Called when the AbstractTraceSink cannot keep up with incoming trace events from Tracks.

This function may be called from any thread.