> Documentation index: https://developer.android.com/reference/llms.txt

# UiDispatcherTracer

Artifact: [androidx.compose.ui:ui](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/platform/AndroidUiDispatcher.android.kt+class:androidx.compose.ui.platform.UiDispatcherTracer) Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01) Common/AllAndroid/JVM
- android

  ```
  interface UiDispatcherTracer
  ```

*** ** * ** ***

Receives trace events from `AndroidUiDispatcher`, 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.

## Summary

| ### Public functions |
|---|---|---|
| `Unit` | `beginSection(name: String, flowIds: LongList)` Begins a trace section named `name`, associated with `flowIds`. | android |
| `Unit` | `counter(name: String, value: Long)` Records `value` for the counter track named `name`. | android |
| `Unit` | `endSection()` Ends the trace section that `beginSection` most recently started on this thread. | android |
| `Unit` | `instant(name: String, flowIds: LongList)` Emits an instant event named `name`, associated with `flowIds`. | android |
| `Boolean` | `isEnabled()` Returns `true` if tracing is currently active. | android |

## Public functions

### beginSection

android Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun beginSection(name: String, flowIds: LongList): Unit
```

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

### counter

android Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun counter(name: String, value: Long): Unit
```

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

### endSection

android Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun endSection(): Unit
```

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

### instant

android Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun instant(name: String, flowIds: LongList): Unit
```

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

### isEnabled

android Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
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.