Skip to content

Commit 7d5276d

Browse files
committed
add replay id to logs even if it's in controller and not in scope
1 parent 4339a9b commit 7d5276d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

sentry/src/main/java/io/sentry/logger/LoggerApi.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ private void captureLog(
221221
final @Nullable SentryId controllerReplayId =
222222
scopes.getOptions().getReplayController().getReplayId();
223223
if (!controllerReplayId.equals(SentryId.EMPTY_ID)) {
224+
attributes.put(
225+
"sentry.replay_id",
226+
new SentryLogEventAttributeValue(
227+
SentryAttributeType.STRING, controllerReplayId.toString()));
224228
attributes.put(
225229
"sentry._internal.replay_is_buffering",
226230
new SentryLogEventAttributeValue(SentryAttributeType.BOOLEAN, true));

sentry/src/test/java/io/sentry/ScopesTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2972,7 +2972,9 @@ class ScopesTest {
29722972
.captureLog(
29732973
check {
29742974
assertEquals("log message", it.body)
2975+
val logReplayId = it.attributes?.get("sentry.replay_id")
29752976
val logReplayType = it.attributes?.get("sentry._internal.replay_is_buffering")
2977+
assertNull(logReplayId)
29762978
assertNull(logReplayType)
29772979
},
29782980
anyOrNull(),
@@ -2991,7 +2993,9 @@ class ScopesTest {
29912993
.captureLog(
29922994
check {
29932995
assertEquals("log message", it.body)
2996+
val logReplayId = it.attributes?.get("sentry.replay_id")
29942997
val logReplayType = it.attributes?.get("sentry._internal.replay_is_buffering")
2998+
assertEquals(replayId.toString(), logReplayId!!.value)
29952999
assertNull(logReplayType)
29963000
},
29973001
anyOrNull(),
@@ -3016,7 +3020,9 @@ class ScopesTest {
30163020
.captureLog(
30173021
check {
30183022
assertEquals("log message", it.body)
3023+
val logReplayId = it.attributes?.get("sentry.replay_id")
30193024
val logReplayType = it.attributes?.get("sentry._internal.replay_is_buffering")!!
3025+
assertEquals(replayId.toString(), logReplayId!!.value)
30203026
assertTrue(logReplayType.value as Boolean)
30213027
},
30223028
anyOrNull(),

0 commit comments

Comments
 (0)