Skip to content

Commit 3bc4794

Browse files
committed
fix: finish root span on late deadline drop and unblock logger assertions in tests
Finish the root span when the deadline timer fires too late so the transaction reads as finished (fixes the device-sleep drop test), enable options.isDebug in the two logger-mock tests so DiagnosticLogger forwards to the mock, and apply spotless formatting. Verified locally: spotlessCheck and the full SentryTracerTest suite pass on JDK 17.
1 parent 97c001f commit 3bc4794

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

sentry/src/main/java/io/sentry/SentryTracer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ private void onDeadlineTimeoutReached() {
165165
SentryLevel.DEBUG,
166166
"Dropping transaction %s because the deadline timer fired too late",
167167
name);
168+
root.finish();
168169
scopes.configureScope(
169170
scope -> {
170171
scope.withTransaction(

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,7 @@ class SentryTracerTest {
965965
optionsConfiguration = {
966966
it.setDateProvider(dateProvider)
967967
it.setLogger(logger)
968+
it.isDebug = true
968969
},
969970
idleTimeout = 60_000,
970971
deadlineTimeout = 10_000,
@@ -975,6 +976,8 @@ class SentryTracerTest {
975976

976977
dateProvider.currentTimeMillis = 30_000
977978
transaction.deadlineTimeoutTask!!.run()
979+
assertThat(transaction.isFinished).isTrue()
980+
transaction.finish()
978981

979982
verify(fixture.scopes, never())
980983
.captureTransaction(anyOrNull(), anyOrNull(), anyOrNull(), anyOrNull())
@@ -1006,8 +1009,7 @@ class SentryTracerTest {
10061009

10071010
assertThat(transaction.isFinished).isTrue()
10081011
assertThat(transaction.status).isEqualTo(SpanStatus.DEADLINE_EXCEEDED)
1009-
verify(fixture.scopes)
1010-
.captureTransaction(any(), anyOrNull(), anyOrNull(), anyOrNull())
1012+
verify(fixture.scopes).captureTransaction(any(), anyOrNull(), anyOrNull(), anyOrNull())
10111013
}
10121014

10131015
@Test
@@ -1023,8 +1025,7 @@ class SentryTracerTest {
10231025
assertEquals(transaction.isFinished, true)
10241026
assertEquals(SpanStatus.OK, transaction.status)
10251027
assertEquals(SpanStatus.OK, span.status)
1026-
verify(fixture.scopes)
1027-
.captureTransaction(any(), anyOrNull(), anyOrNull(), anyOrNull())
1028+
verify(fixture.scopes).captureTransaction(any(), anyOrNull(), anyOrNull(), anyOrNull())
10281029
}
10291030

10301031
@Test
@@ -1036,6 +1037,7 @@ class SentryTracerTest {
10361037
optionsConfiguration = {
10371038
it.setDateProvider(dateProvider)
10381039
it.setLogger(logger)
1040+
it.isDebug = true
10391041
},
10401042
idleTimeout = 60_000,
10411043
deadlineTimeout = 10_000,

0 commit comments

Comments
 (0)