Skip to content
Open
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
- Android: Attachments on the scope will now be synced to native ([#5211](https://github.com/getsentry/sentry-java/pull/5211))
- Add THIRD_PARTY_NOTICES.md for vendored third-party code, bundled as SENTRY_THIRD_PARTY_NOTICES.md in the sentry JAR under META-INF ([#5186](https://github.com/getsentry/sentry-java/pull/5186))

### Fixes

- Write the `sentry-task-enqueued-time` Kafka header as a plain decimal so cross-SDK consumers (e.g. sentry-python) can parse it ([#5328](https://github.com/getsentry/sentry-java/pull/5328))

## 8.37.1

### Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ private void injectHeaders(final @NotNull Headers headers, final @NotNull ISpan
headers.remove(SENTRY_ENQUEUED_TIME_HEADER);
headers.add(
SENTRY_ENQUEUED_TIME_HEADER,
String.valueOf(DateUtils.millisToSeconds(System.currentTimeMillis()))
DateUtils.doubleToBigDecimal(DateUtils.millisToSeconds(System.currentTimeMillis()))
.toString()
.getBytes(StandardCharsets.UTF_8));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertNotNull
import kotlin.test.assertSame
import kotlin.test.assertTrue
Expand Down Expand Up @@ -84,7 +85,19 @@ class SentryKafkaProducerInterceptorTest {
val enqueuedTimeHeader =
record.headers().lastHeader(SentryKafkaProducerInterceptor.SENTRY_ENQUEUED_TIME_HEADER)
assertNotNull(enqueuedTimeHeader)
val enqueuedTime = String(enqueuedTimeHeader.value(), StandardCharsets.UTF_8).toDouble()
val enqueuedTimeRaw = String(enqueuedTimeHeader.value(), StandardCharsets.UTF_8)
// Must be written as a plain decimal so cross-SDK consumers (e.g. sentry-python) can
// parse it. String.valueOf(double) would emit scientific notation (e.g. 1.77E9) for
// epoch seconds.
assertFalse(
enqueuedTimeRaw.contains('E') || enqueuedTimeRaw.contains('e'),
"enqueued-time header must not use scientific notation, got: $enqueuedTimeRaw",
)
assertTrue(
enqueuedTimeRaw.matches(Regex("""^\d+\.\d{6}$""")),
"enqueued-time header must be plain epoch seconds with 6 decimals, got: $enqueuedTimeRaw",
)
val enqueuedTime = enqueuedTimeRaw.toDouble()
assertTrue(enqueuedTime > 0)
}

Expand Down
Loading