# androidx.tracing.wire

*** ** * ** ***

Android/JVM

## Classes

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/tracing/wire/InMemoryRingBufferTraceSink` | A `https://developer.android.com/reference/kotlin/androidx/tracing/AbstractTraceSink` that stores `https://developer.android.com/reference/kotlin/androidx/tracing/TraceEvent`s in a fixed-size ring buffer to minimize allocations. | android |
| `https://developer.android.com/reference/kotlin/androidx/tracing/wire/TraceDriver` | The entry point to tracing APIs. | android |
| `https://developer.android.com/reference/kotlin/androidx/tracing/wire/TraceSink` | The trace sink that writes `https://lysine.dev/okio/3.x/okio/okio/-buffered-sink/index.html`, to a new file per trace session. | android |

## Annotations

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/tracing/wire/ExperimentalRingBufferApi` | Marks declarations in the Tracing API that are highly experimental for ring buffer tracing. | android |

## Top-level functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/tracing/wire/TraceSink` | `https://developer.android.com/reference/kotlin/androidx/tracing/wire/package-summary#TraceSink(java.io.File,kotlin.Int,kotlin.coroutines.CoroutineContext)( directory: https://developer.android.com/reference/java/io/File.html, sequenceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, coroutineContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html )` | android |
| `https://developer.android.com/reference/kotlin/androidx/tracing/wire/TraceSink` | `https://developer.android.com/reference/kotlin/androidx/tracing/wire/package-summary#TraceSink(kotlin.Function0,kotlin.Int,kotlin.coroutines.CoroutineContext)( outputProvider: () -> https://developer.android.com/reference/java/io/OutputStream.html, sequenceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, coroutineContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html )` Creates a `https://developer.android.com/reference/kotlin/androidx/tracing/wire/TraceSink` that writes trace events to the provided `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.io/index.html`. | android |
| `https://developer.android.com/reference/kotlin/androidx/tracing/wire/TraceSink` | `https://developer.android.com/reference/kotlin/androidx/tracing/wire/package-summary#TraceSink(android.content.Context,kotlin.Int,kotlin.coroutines.CoroutineContext,kotlin.Function0)( context: https://developer.android.com/reference/android/content/Context.html, sequenceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, coroutineContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html, fileProvider: () -> https://developer.android.com/reference/java/io/File.html )` Creates a `https://developer.android.com/reference/kotlin/androidx/tracing/wire/TraceSink` that writes trace events to the provided `https://developer.android.com/reference/kotlin/androidx/tracing/wire/package-summary#TraceSink(android.content.Context,kotlin.Int,kotlin.coroutines.CoroutineContext,kotlin.Function0)`. | android |

## Extension functions summary

|---|---|---|
| `https://developer.android.com/reference/java/io/File.html` | `https://developer.android.com/reference/java/io/File.html.https://developer.android.com/reference/kotlin/androidx/tracing/wire/package-summary#(java.io.File).createPerfettoFile(kotlin.String)(prefix: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Creates a `https://developer.android.com/reference/java/io/File.html` that can be used to store in-process trace events. | android |

## Top-level functions

### TraceSink

android Artifact: [androidx.tracing:tracing-wire](https://developer.android.com/jetpack/androidx/releases/tracing) [View Source](https://cs.android.com/search?q=file:androidx/tracing/wire/TraceSink.desktop.kt+function:TraceSink)

```
fun TraceSink(
    directory: File,
    sequenceId: Int = 1,
    coroutineContext: CoroutineContext = Dispatchers.IO + NonCancellable
): TraceSink
```

### TraceSink

android Artifact: [androidx.tracing:tracing-wire](https://developer.android.com/jetpack/androidx/releases/tracing) [View Source](https://cs.android.com/search?q=file:androidx/tracing/wire/TraceSink.android.kt+function:TraceSink)

```
fun TraceSink(
    outputProvider: () -> OutputStream,
    sequenceId: Int = 1,
    coroutineContext: CoroutineContext = Dispatchers.IO + NonCancellable
): TraceSink
```

Creates a `https://developer.android.com/reference/kotlin/androidx/tracing/wire/TraceSink` that writes trace events to the provided `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.io/index.html`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/tracing/wire/TraceSink` |   |

### TraceSink

android Artifact: [androidx.tracing:tracing-wire](https://developer.android.com/jetpack/androidx/releases/tracing) [View Source](https://cs.android.com/search?q=file:androidx/tracing/wire/TraceSink.android.kt+function:TraceSink)

```
fun TraceSink(
    context: Context,
    sequenceId: Int = 1,
    coroutineContext: CoroutineContext = Dispatchers.IO + NonCancellable,
    fileProvider: () -> File = { context.createPerfettoFile() }
): TraceSink
```

Creates a `https://developer.android.com/reference/kotlin/androidx/tracing/wire/TraceSink` that writes trace events to the provided `https://developer.android.com/reference/kotlin/androidx/tracing/wire/package-summary#TraceSink(android.content.Context,kotlin.Int,kotlin.coroutines.CoroutineContext,kotlin.Function0)`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/tracing/wire/TraceSink` |   |

## Extension functions

### File.createPerfettoFile

android Artifact: [androidx.tracing:tracing-wire](https://developer.android.com/jetpack/androidx/releases/tracing) [View Source](https://cs.android.com/search?q=file:androidx/tracing/wire/Files.jvmAndAndroid.kt+function:createPerfettoFile) Added in [2.0.5](https://developer.android.com/jetpack/androidx/releases/tracing#2.0.5)

```
fun File.createPerfettoFile(prefix: String = PREFIX): File
```

Creates a `https://developer.android.com/reference/java/io/File.html` that can be used to store in-process trace events.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/io/File.html` | The parent directory used to store the trace file. ```kotlin // On the JVM File parent = File("/tmp/traces") File trace = parent.createPerfettoFile() ``` ```kotlin // On Android File parent = context.cacheDir File trace = parent.createPerfettoFile() ``` |
| `prefix: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html = PREFIX` | The file name prefix for the trace file. The default value is `perfetto`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/io/File.html` | the trace `https://developer.android.com/reference/java/io/File.html`, for a given parent directory, that can be used by the `https://developer.android.com/reference/kotlin/androidx/tracing/AbstractTraceSink`. |