Skip to content

Commit 50e60d4

Browse files
authored
feat(spans): Attachment V2 envelope item (#15466)
1 parent 34301b0 commit 50e60d4

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,52 @@ Example:
220220
trace_id: "6cf173d587eb48568a9b2e12dcfbea52"
221221
span_id: "438f40bd3b4a41ee"
222222
```
223+
224+
## Span Attachments
225+
226+
The SDK must implement a new "attachment v2" envelope item, which is used to emit span attachments to Sentry. A span attachment should be emitted in the same envelope as its owner span, so that it can be dropped when the span itself is filtered or rate limited.
227+
228+
### Attachment v2 Envelope Item Header
229+
230+
The envelope item header must contain the following properties:
231+
232+
```json
233+
{
234+
"type": "attachment",
235+
"content_type": "application/vnd.sentry.attachment.v2",
236+
"length": 212341234,
237+
"meta_length": 123,
238+
"span_id": "abcd1234" // or `null`
239+
}
240+
```
241+
242+
- `meta_length` is the size of the metadata portion of the payload in bytes (see item description below).
243+
- `span_id` is the ID of the span that owns the attachment. `span_id: null` is treated as “owned by spans”, but not owned by a specific span. That is, the attachment can be dropped if the span quota is exceeded, but it will not be dropped with a specific span because of e.g. inbound filters.
244+
245+
## Attachment v2 Envelope Item Payload
246+
247+
The attachment item payload consists of JSON object containing metadata followed by the attachment body. For example, for a plain text attachment with the body "Hello World!", the item payload would look like this:
248+
249+
```json
250+
{ // Attachment Metadata
251+
"attachment_id": "019a72d07ffe77208c013ac888b38d9e",
252+
"timestamp": 1760520026.781239,
253+
"filename": "myfile.txt",
254+
"content_type": "text/plain",
255+
"attributes": {
256+
// Arbitrary key value pairs that will end up in EAP.
257+
"foo": {"type": "string", "value": "bar"}
258+
}
259+
}helloworld
260+
```
261+
262+
| Property | Type | Required | Description |
263+
|----------|------|----------|-------------|
264+
| `attachment_id` | string | Yes | 32-character hexadecimal string (a valid [Version 7](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_7_(timestamp_and_random)) or Version 4 UUID without dashes) |
265+
| `timestamp` | float | Yes | a UNIX timestamp corresponding to the attachment's occurrence. It may be the same as the start or end timestamp of the owner span. |
266+
| `filename` | string | No | The file name of the attachment. |
267+
| `content_type` | string | Yes | the content type of the attachment body (not to be confused with the content type of the envelope item, which is always `application/vnd.sentry.attachment.v2`). |
268+
| `attributes` | object | No | arbitrary attributes that will be queryable on the attachment trace item, similar to spans, logs, and trace metrics. |
269+
270+
271+

0 commit comments

Comments
 (0)