Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

### Fixes

- Session Replay: Send Ktor client network request start and end times in milliseconds, so the requests line up with the replay ([#6619](https://github.com/getsentry/sentry-java/pull/6619))
- Nav3: Stop attributing errors and spans from an Activity or ViewPager2 page without a `SentryNavEffect` to the most recently visited Nav3 root ([#6483](https://github.com/getsentry/sentry-java/pull/6483))
- Android: Count deep sleep in breadcrumb, screenshot and view hierarchy debounce windows, so the first low-memory or battery breadcrumb after a long Doze is no longer dropped ([#6590](https://github.com/getsentry/sentry-java/pull/6590))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import io.sentry.protocol.Mechanism
import io.sentry.util.CookieUtils
import io.sentry.util.HttpUtils
import io.sentry.util.UrlUtils
import java.util.concurrent.TimeUnit

internal object SentryKtorClientUtils {
internal suspend fun captureClientError(
Expand Down Expand Up @@ -126,16 +127,17 @@ internal object SentryKtorClientUtils {
SpanDataConvention.HTTP_RESPONSE_CONTENT_LENGTH_KEY,
response.contentLength(),
)
// Session Replay reads these as epoch milliseconds for its rrweb network spans.
if (startTimestamp != null) {
breadcrumb.setData(
SpanDataConvention.HTTP_START_TIMESTAMP,
startTimestamp.nanoTimestamp() / 1000L,
TimeUnit.NANOSECONDS.toMillis(startTimestamp.nanoTimestamp()),
)
}
if (endTimestamp != null) {
breadcrumb.setData(
SpanDataConvention.HTTP_END_TIMESTAMP,
endTimestamp.nanoTimestamp() / 1000L,
TimeUnit.NANOSECONDS.toMillis(endTimestamp.nanoTimestamp()),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ import io.sentry.Scope
import io.sentry.ScopeCallback
import io.sentry.ScopeType
import io.sentry.Sentry
import io.sentry.SentryDateProvider
import io.sentry.SentryEvent
import io.sentry.SentryLevel
import io.sentry.SentryNanotimeDate
import io.sentry.SentryOptions
import io.sentry.SentryTraceHeader
import io.sentry.SentryTracer
Expand Down Expand Up @@ -155,6 +157,27 @@ class SentryKtorClientPluginTest {
)
}

@Test
fun `breadcrumb timestamps are epoch milliseconds`(): Unit = runBlocking {
val epochMillis = 1_700_000_000_123L
val sut =
fixture.getSut(
optionsConfiguration = { options ->
options.dateProvider = SentryDateProvider { SentryNanotimeDate(epochMillis, 0) }
},
)
sut.get(fixture.server.url("/hello").toString())

verify(fixture.scopes)
.addBreadcrumb(
check<Breadcrumb> {
assertThat(it.getData(SpanDataConvention.HTTP_START_TIMESTAMP)).isEqualTo(epochMillis)
assertThat(it.getData(SpanDataConvention.HTTP_END_TIMESTAMP)).isEqualTo(epochMillis)
},
anyOrNull(),
)
}

@Test
fun `adds breadcrumb when http call fails`(): Unit = runBlocking {
val sut = fixture.getSut(httpStatusCode = 500, responseBody = "error")
Expand Down
Loading