Skip to content

Commit 74ba9ad

Browse files
cleptricLms24
andauthored
docs(spans): Create a dedicated attributes page (#15557)
Co-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
1 parent c6c0a83 commit 74ba9ad

File tree

5 files changed

+96
-20
lines changed

5 files changed

+96
-20
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
title: Attributes
3+
sidebar_order: 2
4+
---
5+
6+
This document defines the format used by Sentry to represent attributes across different telemetry data types (Spans, Logs, Metrics).
7+
8+
## Attribute Object Structure
9+
10+
Attributes are stored as key-value pairs where each value is an object with type information.
11+
12+
```json
13+
{
14+
"my_attribute": {
15+
"value": "some value",
16+
"type": "string"
17+
},
18+
"response_time": {
19+
"value": 123,
20+
"unit": "millisecond",
21+
"type": "integer"
22+
}
23+
}
24+
```
25+
26+
### Properties
27+
28+
| Property | Type | Required | Description |
29+
|----------|------|----------|-------------|
30+
| `type` | string | Yes | The data type of the attribute value. |
31+
| `value` | any | Yes | The actual attribute value, must match the specified type. |
32+
| `unit` | string | No | The unit of the attribute value. See [Units](#units) for a full list of supported units. |
33+
34+
### Supported Types
35+
36+
The following types are supported:
37+
38+
- `string`
39+
- `boolean`
40+
- `integer` (64-bit signed integer)
41+
- `double` (64-bit floating point number)
42+
- `string[]`
43+
- `boolean[]`
44+
- `integer[]`
45+
- `double[]`
46+
47+
**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.
48+
49+
## Units
50+
51+
The following units are [supported by Relay](https://getsentry.github.io/relay/relay_metrics/enum.MetricUnit.html).
52+
53+
### Duration Units
54+
55+
- `nanosecond`
56+
- `microsecond`
57+
- `millisecond`
58+
- `second`
59+
- `minute`
60+
- `hour`
61+
- `day`
62+
- `week`
63+
64+
### Information Units
65+
66+
- `bit`
67+
- `byte`
68+
- `kilobyte`
69+
- `kibibyte`
70+
- `megabyte`
71+
- `mebibyte`
72+
- `gigabyte`
73+
- `gibibyte`
74+
- `terabyte`
75+
- `tebibyte`
76+
- `petabyte`
77+
- `pebibyte`
78+
- `exabyte`
79+
- `exbibyte`
80+
81+
### Fraction Units
82+
83+
- `ratio`
84+
- `percent`
85+
86+
## Semantic Conventions
87+
88+
See [Sentry Conventions](https://github.com/getsentry/sentry-conventions/) for a full list of supported attributes.
89+

develop-docs/sdk/telemetry/logs.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ It consists of the following fields:
8282

8383
`attributes`
8484

85-
: **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[]`).
86-
87-
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.
85+
: **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.
8886

8987
Example:
9088

develop-docs/sdk/telemetry/metrics.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Integers should be a 64-bit signed integer, while doubles should be a 64-bit flo
9292

9393
`attributes`
9494

95-
: **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`.
95+
: **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.
9696

9797
Example with multiple attribute types:
9898

develop-docs/sdk/telemetry/scopes.mdx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,14 @@ Data from all three scope types MUST be merged in a specific order before being
5656

5757
### Setting Attributes
5858

59-
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).
59+
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.
6060

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

6363
- `value`: The actual attribute value, which MUST match the specified type
64-
- `unit` (optional): The unit of measurement (e.g., `"millisecond"`, `"second"`, `"byte"`, `"ratio"`).
64+
- `unit` (optional): The unit of measurement. See [Units](/sdk/telemetry/attributes#units) for the full list of supported units.
6565
- 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.
66-
- 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'`).
67-
- `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.
66+
- `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.
6867

6968
#### Example Usage
7069

@@ -105,7 +104,7 @@ The method SHOULD accept a dictionary/map/object where:
105104
- 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.
106105
- Calling `scope.clear()` MUST remove all attributes from the corresponding scope.
107106

108-
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.
107+
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.
109108

110109
### Removing Attributes
111110

develop-docs/sdk/telemetry/spans/span-protocol.mdx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,6 @@ The envelope item payload must contain an `items` array with span one and up to
157157
| `attributes` | object | No | Key-value pairs containing additional metadata about the span |
158158
| `links` | array | No | Array of links connecting this span to other spans or traces |
159159

160-
### Attribute Object Properties
161-
162-
Attributes are stored as key-value pairs where each value is an object with type information:
163-
164-
| Property | Type | Required | Description |
165-
|----------|------|----------|-------------|
166-
| `type` | string | Yes | The data type of the attribute value. Values: `"string"`, `"integer"`, `"double"`, `"boolean"`, `"string[]"`, `"integer[]"`, `"double[]"`, `"boolean[]"` |
167-
| `value` | any | Yes | The actual attribute value, must match the specified type |
168-
| `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. |
169-
170160
#### Common Attribute Keys
171161

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

0 commit comments

Comments
 (0)