# TraceAttributes

Artifact: [androidx.tracing:tracing](https://developer.android.com/jetpack/androidx/releases/tracing) [View Source](https://cs.android.com/search?q=file:androidx/tracing/TraceAttributes.kt+class:androidx.tracing.TraceAttributes) Added in [2.0.5](https://developer.android.com/jetpack/androidx/releases/tracing#2.0.5)

*** ** * ** ***


```
public abstract class TraceAttributes
```

<br />

*** ** * ** ***

Makes it possible to associate key value pairs to be attached to a trace to provide additional context about any facet of the trace. This can include what data it contains, and properties of the host / machine the trace was collected on, and other interesting information about a trace.

Examples include:

```
gradle_version = "9.0.10-alpha01"
java_major_version = 24
```

All keys get prefixed with `trace_attribute.` in Perfetto UI and in `traceprocessor`. If there are multiple trace attributes that use the same key then the last value wins.

These key value pairs show up in the `Overview` section in Perfetto UI. Additionally, these key, value pairs can be queried using Perfetto SQL using the following query:

```
SELECT * FROM metadata WHERE name GLOB 'trace_attribute.*';
```

## Summary

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/tracing/TraceAttributes#addAttribute(kotlin.String,kotlin.Long)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html name, long value)` Adds a trace attribute entry where the type of the `https://developer.android.com/reference/androidx/tracing/TraceAttributes#addAttribute(kotlin.String,kotlin.Long)` is a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html`. |
| `abstract void` | `https://developer.android.com/reference/androidx/tracing/TraceAttributes#addAttribute(kotlin.String,kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html name, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html value)` Adds a trace attribute entry where the type of the `https://developer.android.com/reference/androidx/tracing/TraceAttributes#addAttribute(kotlin.String,kotlin.String)` is a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html`. |
| `abstract void` | `@https://developer.android.com/reference/androidx/tracing/DelicateTracingApi https://developer.android.com/reference/androidx/tracing/TraceAttributes#dispatchToTraceSink()()` Dispatches the underlying `https://developer.android.com/reference/androidx/tracing/TraceEvent` to the `https://developer.android.com/reference/androidx/tracing/AbstractTraceSink` instance if applicable. |

## Public methods

### addAttribute

Added in [2.0.5](https://developer.android.com/jetpack/androidx/releases/tracing#2.0.5)

```
public abstract void addAttribute(@NonNull String name, long value)
```

Adds a trace attribute entry where the type of the `https://developer.android.com/reference/androidx/tracing/TraceAttributes#addAttribute(kotlin.String,kotlin.Long)` is a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html`.

### addAttribute

Added in [2.0.5](https://developer.android.com/jetpack/androidx/releases/tracing#2.0.5)

```
public abstract void addAttribute(@NonNull String name, @NonNull String value)
```

Adds a trace attribute entry where the type of the `https://developer.android.com/reference/androidx/tracing/TraceAttributes#addAttribute(kotlin.String,kotlin.String)` is a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html`.

### dispatchToTraceSink

Added in [2.0.5](https://developer.android.com/jetpack/androidx/releases/tracing#2.0.5)

```
@DelicateTracingApi
public abstract void dispatchToTraceSink()
```

Dispatches the underlying `https://developer.android.com/reference/androidx/tracing/TraceEvent` to the `https://developer.android.com/reference/androidx/tracing/AbstractTraceSink` instance if applicable.