Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions develop-docs/sdk/telemetry/attributes.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
title: Attributes
sidebar_order: 2
---

This document defines the format used by Sentry to represent attributes across different telemetry data types (Spans, Logs, Metrics).

## Attribute Object Structure

Attributes are stored as key-value pairs where each value is an object with type information.

```json
{
"my_attribute": {
"value": "some value",
"type": "string"
},
"response_time": {
"value": 123,
"unit": "millisecond",
"type": "integer"
}
}
```

### Properties

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `type` | string | Yes | The data type of the attribute value. |
| `value` | any | Yes | The actual attribute value, must match the specified type. |
| `unit` | string | No | The unit of the attribute value. See [Units](#units) for a full list of supported units. |

### Supported Types

The following types are supported:

- `string`
- `boolean`
- `integer` (64-bit signed integer)
- `double` (64-bit floating point number)
- `string[]`
- `boolean[]`
- `integer[]`
- `double[]`
Comment on lines +44 to +45
Copy link
Member

@Lms24 Lms24 Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder that we still have to figure out what should happen with mixed number arrays (integers and doubles). Not a blocker though.


**Note on Integers:** Integers should be 64-bit signed integers. For 64-bit unsigned integers, use the `string` type to avoid overflow issues until unsigned integers are natively supported.

## Units

The following units are supported by Relay.

### Duration Units

Defaults to `millisecond`.

- `nanosecond`
- `microsecond`
- `millisecond`
- `second`
- `minute`
- `hour`
- `day`
- `week`

### Information Units

Defaults to `byte`.

- `bit`
- `byte`
- `kilobyte`
- `kibibyte`
- `megabyte`
- `mebibyte`
- `gigabyte`
- `gibibyte`
- `terabyte`
- `tebibyte`
- `petabyte`
- `pebibyte`
- `exabyte`
- `exbibyte`

### Fraction Units

Defaults to `ratio`.

- `ratio`
- `percent`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when will it default to milliseconds / byte /ratio? can relay infer what type of unit it is if none is provided?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relay will default to none if no unit was provided. SDKs will not send it though, so you just omit the unit property.


## Semantic Conventions

See [Sentry Conventions](https://github.com/getsentry/sentry-conventions/) for a full list of supported attributes.

4 changes: 1 addition & 3 deletions develop-docs/sdk/telemetry/logs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ It consists of the following fields:

`attributes`

: **Object, optional**. A dictionary of key-value pairs of arbitrary data attached to the log. Attributes must also declare the type of the value. The following types are supported: `string`, `boolean`, `integer`, `double`. In the future arrays will be supported (`string[]`, `boolean[]`, `integer[]`, `double[]`).

Integers should be a 64-bit signed integer, while doubles should be a 64-bit floating point number. For 64-bit unsigned integers, use the `string` type to avoid overflow issues. Make sure to always convert 64-bit unsigned integers to strings regardless of if they are in or out of the 64-bit signed range. In the future we will support sending 64-bit unsigned integers without converting them to strings.
: **Object, optional**. A dictionary of key-value pairs of arbitrary data attached to the log. Attributes must also declare the type of the value. See [Attributes](/sdk/telemetry/attributes) for the supported types and structure.

Example:

Expand Down
2 changes: 1 addition & 1 deletion develop-docs/sdk/telemetry/metrics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Integers should be a 64-bit signed integer, while doubles should be a 64-bit flo

`attributes`

: **Object, optional**. A dictionary of key-value pairs of arbitrary data attached to the metric. Attributes must also declare the type of the value. The following types are supported: `string`, `boolean`, `integer`, `double`.
: **Object, optional**. A dictionary of key-value pairs of arbitrary data attached to the metric. Attributes must also declare the type of the value. See [Attributes](/sdk/telemetry/attributes) for the supported types and structure.

Example with multiple attribute types:

Expand Down
11 changes: 5 additions & 6 deletions develop-docs/sdk/telemetry/scopes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,14 @@ Data from all three scope types MUST be merged in a specific order before being

### Setting Attributes

Users MUST be able to attach attributes to any scope using a dedicated method (e.g., `scope.setAttributes()` or `scope.setAttribute()`). These attributes follow the structure defined in the [Span Protocol](/sdk/telemetry/spans/span-protocol/#attribute-object-properties).
Users MUST be able to attach attributes to any scope using a dedicated method (e.g., `scope.setAttributes()` or `scope.setAttribute()`). These attributes follow the structure defined in the [Attributes](/sdk/telemetry/attributes) documentation.

Attributes are key-value pairs where each value is either a an attribute value or an object containing:
Attributes are key-value pairs where each value is either an attribute value or an object containing:

- `value`: The actual attribute value, which MUST match the specified type
- `unit` (optional): The unit of measurement (e.g., `"millisecond"`, `"second"`, `"byte"`, `"ratio"`).
- `unit` (optional): The unit of measurement. See [Units](/sdk/telemetry/attributes#units) for the full list of supported units.
- SDKs MAY delay adding support for units for the moment, but MUST be able to do so at a later date without a breaking change.
- SDKS MUST allow setting all units supported by Relay's [`MetricUnit` enum](https://getsentry.github.io/relay/relay_metrics/enum.MetricUnit.html) but MUST NOT allow custom units (i.e. arbitrary strings, defined in [`CustomUnit`](https://getsentry.github.io/relay/relay_metrics/struct.CustomUnit.html)) or "none" units (`''` or `'none'`).
- `type` (optional): The type of the attribute. SDKs SHOULD NOT expose this to users if they can reliably infer the type from the value. If not, SDKs MAY allow or require users to set the `type` explicitly.
- `type` (optional): The type of the attribute. See [Supported Types](/sdk/telemetry/attributes#supported-types) for the full list. SDKs SHOULD NOT expose this to users if they can reliably infer the type from the value. If not, SDKs MAY allow or require users to set the `type` explicitly.

#### Example Usage

Expand Down Expand Up @@ -104,7 +103,7 @@ The method SHOULD accept a dictionary/map/object where:
- When the same attribute key exists on the current log or metric, it MUST take precedence over an attribute with the same key set on any scope (log/metric > current > isolation > global)
- The SDK SHOULD keep the attribute format consistent with the user-set format until user-provided processing callbacks like `before_send_log` have been called. This ensures compatibility with already existing callbacks and avoids unexpected changes to the attribute format.

See [Span Protocol - Common Attribute Keys](/sdk/telemetry/spans/span-protocol/#common-attribute-keys) for a list of standard attributes and [Sentry Conventions](https://github.com/getsentry/sentry-conventions/) for the complete attribute registry.
See [Attributes](/sdk/telemetry/attributes) for detailed information about attribute structure, supported types, units, and common attribute keys. Also see [Sentry Conventions](https://github.com/getsentry/sentry-conventions/) for the complete attribute registry.

### Removing Attributes

Expand Down
10 changes: 0 additions & 10 deletions develop-docs/sdk/telemetry/spans/span-protocol.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,6 @@ The envelope item payload must contain an `items` array with span one and up to
| `attributes` | object | No | Key-value pairs containing additional metadata about the span |
| `links` | array | No | Array of links connecting this span to other spans or traces |

### Attribute Object Properties

Attributes are stored as key-value pairs where each value is an object with type information:

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `type` | string | Yes | The data type of the attribute value. Values: `"string"`, `"integer"`, `"double"`, `"boolean"`, `"string[]"`, `"integer[]"`, `"double[]"`, `"boolean[]"` |
| `value` | any | Yes | The actual attribute value, must match the specified type |
| `unit` | string | No | The unit of the attribute value. Example values: `"millisecond"`, `"second"`, `"byte"`, `"ratio"`. Units MUST be one of the [MetricUnit](https://getsentry.github.io/relay/relay_metrics/enum.MetricUnit.html)s supported by Relay, excluding `""`, `"none"` or custom units. |

#### Common Attribute Keys

All attributes mentioned below must be attached to every span being emitted from the SDK, depending on the platform.
Expand Down
Loading