Skip to content

Commit 28a2d01

Browse files
authored
feat(logs): Add sentry.replay_id to logs spec (#14838)
resolves https://linear.app/getsentry/issue/SDK-35/update-develop-docs-to-mention-sentryreplay-id-attribute Attaching a replay id directly to logs makes it easy for users to go from log -> replay. It also vastly simplifies querying for logs in the frontend. Right now we have only specced attaching replay to client-side logs, but in the future we can add the functionality that sdks can parse baggage to grab the `replay_id` and attach the id to logs.
1 parent c631ab4 commit 28a2d01

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

develop-docs/sdk/telemetry/logs.mdx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,16 @@ By default the SDK should attach the following attributes to a log:
275275
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.
276276
4. `sentry.sdk.name`: The name of the SDK that sent the log
277277
5. `sentry.sdk.version`: The version of the SDK that sent the log
278+
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.
278279

279280
```json
280281
{
281282
"sentry.environment": "production",
282283
"sentry.release": "1.0.0",
283284
"sentry.trace.parent_span_id": "b0e6f15b45c36b12",
284285
"sentry.sdk.name": "sentry.javascript.node",
285-
"sentry.sdk.version": "9.11.0"
286+
"sentry.sdk.version": "9.11.0",
287+
"sentry.replay_id": "36b75d9fa11f45459412a96c41bdf691"
286288
}
287289
```
288290

@@ -393,6 +395,16 @@ SDKs should aim to have it so that console/logger integrations create logs as pe
393395

394396
If SDK authors feel the need, they can also introduce additional options to beyond `enableLogs`/`enable_logs` to gate this functionality. For example an option to control log appenders added via external config like with `Log4j` in the Java SDK.
395397

398+
### Behaviour with other Sentry Telemetry
399+
400+
#### Tracing
401+
402+
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.
403+
404+
#### Replays
405+
406+
Logs should be associated with replays if possible. If a log is recorded during an active replay, the SDK should set the `sentry.replay_id` attribute to the replay id of the replay that was active when the log was collected.
407+
396408
### Other
397409

398410
If `debug` is set to `true` in SDK init, calls to the Sentry logger API should also print to the console with the appropriate log level. This will help debugging logging setups.

0 commit comments

Comments
 (0)