# UiDispatcherTracer

> Receives trace events from [AndroidUiDispatcher], for tools that record how tasks and frame callbacks are queued and run.

## API Reference

> Source set: Android

```kotlin
public interface UiDispatcherTracer
```

Receives trace events from [AndroidUiDispatcher](https://composables.com/jetpack-compose/androidx.compose.ui/ui/classes/AndroidUiDispatcher/api.md), for tools that record how tasks and frame
callbacks are queued and run. Install one with `AndroidUiDispatcher.setTracer`.

The dispatcher may call `instant` and `counter` from any thread, since tasks reach it from
arbitrary threads, and calls `beginSection` and `endSection` on its own thread. It calls all of
them once per dispatched task, so implementations should not be expensive.

Event names, counter names and flow IDs reflect the dispatcher's internal behavior and may change
between releases.

## Functions

### instant

> Source set: Android

```kotlin
public fun instant(name: String, flowIds: LongList)
```

Emits an instant event named `name`, associated with `flowIds`.

### beginSection

> Source set: Android

```kotlin
public fun beginSection(name: String, flowIds: LongList)
```

Begins a trace section named `name`, associated with `flowIds`. Match this with a
corresponding `endSection` on the same thread.

### endSection

> Source set: Android

```kotlin
public fun endSection()
```

Ends the trace section that `beginSection` most recently started on this thread.

### counter

> Source set: Android

```kotlin
public fun counter(name: String, value: Long)
```

Records `value` for the counter track named `name`.

### isEnabled

> Source set: Android

```kotlin
public fun isEnabled(): Boolean
```

Returns `true` if tracing is currently active.

The dispatcher calls this before doing any work to build trace arguments, so it should not be
expensive.
