Skip to content

Commit 0e90f25

Browse files
authored
Change the logs protocol to incldue the span_id (#15355)
1 parent fef6ddc commit 0e90f25

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

develop-docs/sdk/telemetry/logs.mdx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ The `log` envelope item payload is a JSON object that represents a Sentry Log.
4040
{
4141
"timestamp": 1544719860.0,
4242
"trace_id": "5b8efff798038103d269b633813fc60c",
43+
"span_id": "b0e6f15b45c36b12",
4344
"level": "info",
4445
"body": "User John has logged in!",
4546
"attributes": {
@@ -58,10 +59,6 @@ The `log` envelope item payload is a JSON object that represents a Sentry Log.
5859
"sentry.release": {
5960
"value": "1.0.0",
6061
"type": "string"
61-
},
62-
"sentry.trace.parent_span_id": {
63-
"value": "b0e6f15b45c36b12",
64-
"type": "string"
6562
}
6663
}
6764
}
@@ -77,6 +74,10 @@ It consists of the following fields:
7774

7875
: **String, required**. The trace id of the log. The value should be 16 random bytes encoded as a hex string (32 characters long). The trace id should be grabbed from the current propagation context in the SDK.
7976

77+
`span_id`
78+
79+
: **String, optional**. The span id of the span that was active when the log was collected. The value should be 8 random bytes encoded as a hex string (16 characters long). The span id should be grabbed from the current active span in the SDK.
80+
8081
`level`
8182

8283
: **String, required**. The severity level of the log. One of `trace`, `debug`, `info`, `warn`, `error`, `fatal` (in order of lowest to highest).
@@ -274,16 +275,14 @@ By default the SDK should attach the following attributes to a log:
274275

275276
1. `sentry.environment`: The environment set in the SDK if defined.
276277
2. `sentry.release`: The release set in the SDK if defined.
277-
3. `sentry.trace.parent_span_id`: The span id of the span that was active when the log was collected. This should not be set if there was no active span.
278-
4. `sentry.sdk.name`: The name of the SDK that sent the log
279-
5. `sentry.sdk.version`: The version of the SDK that sent the log
280-
6. `sentry.replay_id`: The replay id of the replay that was active when the log was collected. This should not be set if there was no active replay.
278+
3. `sentry.sdk.name`: The name of the SDK that sent the log
279+
4. `sentry.sdk.version`: The version of the SDK that sent the log
280+
5. `sentry.replay_id`: The replay id of the replay that was active when the log was collected. This should not be set if there was no active replay.
281281

282282
```json
283283
{
284284
"sentry.environment": "production",
285285
"sentry.release": "1.0.0",
286-
"sentry.trace.parent_span_id": "b0e6f15b45c36b12",
287286
"sentry.sdk.name": "sentry.javascript.node",
288287
"sentry.sdk.version": "9.11.0",
289288
"sentry.replay_id": "36b75d9fa11f45459412a96c41bdf691"
@@ -411,7 +410,7 @@ If SDK authors feel the need, they can also introduce additional options to beyo
411410

412411
#### Tracing
413412

414-
Logs should be associated with traces if possible. If a log is recorded during an active span, the SDK should set the `sentry.trace.parent_span_id` attribute to the span id of the span that was active when the log was collected.
413+
Logs should be associated with traces if possible. If a log is recorded during an active span, the SDK should set the `span_id` property of the log to the span id of the span that was active when the log was collected.
415414

416415
#### Replays
417416

0 commit comments

Comments
 (0)