Skip to content
Draft
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 @@ -36,6 +36,7 @@

### Fixes

- Fix transaction-specific dynamic sampling context fields missing after earlier spanless outgoing requests ([#5384](https://github.com/getsentry/sentry-java/pull/5384))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 🚫 The changelog entry seems to be part of an already released section ## 8.41.0.
    Consider moving the entry to the ## Unreleased section, please.

- Fix soft input keyboard not being shown on the Feedback form ([#5359](https://github.com/getsentry/sentry-java/pull/5359))
- Fix shake-to-report not triggering on some devices due to high acceleration threshold ([#5366](https://github.com/getsentry/sentry-java/pull/5366))
- Fix feedback form retaining previous message when shown again via shake ([#5366](https://github.com/getsentry/sentry-java/pull/5366))
Expand Down
4 changes: 3 additions & 1 deletion sentry/src/main/java/io/sentry/util/TracingUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ public static void setTrace(
@NotNull Baggage baggage = propagationContext.getBaggage();
if (baggage.isMutable()) {
baggage.setValuesFromScope(scope, sentryOptions);
baggage.freeze();
if (baggage.isShouldFreeze()) {
baggage.freeze();
}
}
});
}
Expand Down
43 changes: 36 additions & 7 deletions sentry/src/test/java/io/sentry/util/TracingUtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import io.sentry.TracesSamplingDecision
import io.sentry.TransactionContext
import io.sentry.W3CTraceparentHeader
import io.sentry.protocol.SentryId
import io.sentry.protocol.TransactionNameSource
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertNotEquals
Expand Down Expand Up @@ -77,7 +78,7 @@ class TracingUtilsTest {
.value
.contains("sentry-trace_id=${fixture.scope.propagationContext.traceId}")
)
assertFalse(fixture.scope.propagationContext.baggage!!.isMutable)
assertTrue(fixture.scope.propagationContext.baggage!!.isMutable)
}

@Test
Expand All @@ -98,7 +99,7 @@ class TracingUtilsTest {
assertEquals(fixture.scope.propagationContext.traceId, headers.sentryTraceHeader.traceId)
assertEquals(fixture.scope.propagationContext.isSampled, headers.sentryTraceHeader.isSampled)
assertTrue(headers.baggageHeader!!.value.contains("some-baggage-key=some-baggage-value"))
assertFalse(fixture.scope.propagationContext.baggage!!.isMutable)
assertTrue(fixture.scope.propagationContext.baggage!!.isMutable)
}

@Test
Expand All @@ -120,7 +121,7 @@ class TracingUtilsTest {
assertEquals(fixture.scope.propagationContext.traceId, headers.sentryTraceHeader.traceId)
assertEquals(fixture.scope.propagationContext.isSampled, headers.sentryTraceHeader.isSampled)
assertTrue(headers.baggageHeader!!.value.contains("some-baggage-key=some-baggage-value"))
assertFalse(fixture.scope.propagationContext.baggage!!.isMutable)
assertTrue(fixture.scope.propagationContext.baggage!!.isMutable)
}

@Test
Expand All @@ -142,7 +143,7 @@ class TracingUtilsTest {
assertEquals(fixture.scope.propagationContext.traceId, headers.sentryTraceHeader.traceId)
assertEquals(fixture.scope.propagationContext.isSampled, headers.sentryTraceHeader.isSampled)
assertTrue(headers.baggageHeader!!.value.contains("some-baggage-key=some-baggage-value"))
assertFalse(fixture.scope.propagationContext.baggage!!.isMutable)
assertTrue(fixture.scope.propagationContext.baggage!!.isMutable)
}

@Test
Expand All @@ -164,7 +165,7 @@ class TracingUtilsTest {
assertEquals(fixture.scope.propagationContext.traceId, headers.sentryTraceHeader.traceId)
assertEquals(fixture.scope.propagationContext.isSampled, headers.sentryTraceHeader.isSampled)
assertTrue(headers.baggageHeader!!.value.contains("some-baggage-key=some-baggage-value"))
assertFalse(fixture.scope.propagationContext.baggage!!.isMutable)
assertTrue(fixture.scope.propagationContext.baggage!!.isMutable)
}

@Test
Expand Down Expand Up @@ -301,7 +302,7 @@ class TracingUtilsTest {
}

@Test
fun `updates mutable baggage`() {
fun `updates mutable baggage without freezing local baggage`() {
fixture.setup()
// not frozen because it doesn't contain sentry-* keys
fixture.scope.propagationContext =
Expand All @@ -319,7 +320,35 @@ class TracingUtilsTest {
fixture.scope.propagationContext.traceId.toString(),
fixture.scope.propagationContext.baggage!!.traceId,
)
assertFalse(fixture.scope.propagationContext.baggage!!.isMutable)
assertTrue(fixture.scope.propagationContext.baggage!!.isMutable)
}

@Test
fun `spanless propagation leaves baggage mutable for later transaction DSC`() {
fixture.setup()
val propagationContext = fixture.scope.propagationContext

TracingUtils.maybeUpdateBaggage(fixture.scope, fixture.options)

assertTrue(propagationContext.baggage.isMutable)
assertNull(propagationContext.baggage.transaction)
assertNull(propagationContext.baggage.sampleRate)
assertNull(propagationContext.baggage.sampled)

val transactionContext = TransactionContext.fromPropagationContext(propagationContext)
transactionContext.name = "GET /session"
transactionContext.transactionNameSource = TransactionNameSource.CUSTOM
transactionContext.setSamplingDecision(
TracesSamplingDecision(true, 0.5, propagationContext.sampleRand)
)
val tracer = SentryTracer(transactionContext, fixture.scopes)

val baggageHeader = tracer.toBaggageHeader(null)

assertNotNull(baggageHeader)
assertTrue(baggageHeader.value.contains("sentry-transaction=GET%20%2Fsession"))
assertTrue(baggageHeader.value.contains("sentry-sampled=true"))
assertTrue(baggageHeader.value.contains("sentry-sample_rate=0.5"))
}

@Test
Expand Down
Loading