Skip to content

Commit cd713a4

Browse files
committed
Revert "fix(core): Stop unfreezing Baggage"
This reverts commit bb4cac3.
1 parent bb4cac3 commit cd713a4

4 files changed

Lines changed: 11 additions & 26 deletions

File tree

sentry/src/main/java/io/sentry/Baggage.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,23 +221,21 @@ public Baggage(final @NotNull Baggage baggage) {
221221

222222
@ApiStatus.Internal
223223
static @NotNull Baggage copyWithOverrides(
224-
final @Nullable Baggage baggage,
224+
final @NotNull Baggage baggage,
225225
final @NotNull SentryId traceId,
226226
final @Nullable Double sampleRand) {
227-
final @NotNull Baggage source =
228-
baggage == null ? new Baggage(NoOpLogger.getInstance()) : baggage;
229227
final @NotNull ConcurrentHashMap<String, String> keyValues =
230-
new ConcurrentHashMap<>(source.keyValues);
228+
new ConcurrentHashMap<>(baggage.keyValues);
231229
keyValues.put(DSCKeys.TRACE_ID, traceId.toString());
232230

233231
return new Baggage(
234232
keyValues,
235-
source.sampleRate,
233+
baggage.sampleRate,
236234
sampleRand,
237-
source.thirdPartyHeader,
238-
source.mutable,
239-
source.shouldFreeze,
240-
source.logger);
235+
baggage.thirdPartyHeader,
236+
true,
237+
false,
238+
baggage.logger);
241239
}
242240

243241
@ApiStatus.Internal

sentry/src/main/java/io/sentry/TransactionContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static TransactionContext fromPropagationContext(
4444
final @NotNull TransactionContext transactionContext) {
4545
final @NotNull Baggage baggage =
4646
Baggage.copyWithOverrides(
47-
transactionContext.getBaggage(),
47+
propagationContext.getBaggage(),
4848
propagationContext.getTraceId(),
4949
propagationContext.getSampleRand());
5050

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

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ class BaggageTest {
440440
}
441441

442442
@Test
443-
fun `copy with overrides preserves frozen state`() {
443+
fun `copy with overrides creates mutable baggage`() {
444444
val baggage =
445445
Baggage.fromHeader(
446446
"sentry-sample_rand=0.1,sentry-trace_id=75302ac48a024bde9a3b3734a82e36c8",
@@ -450,22 +450,12 @@ class BaggageTest {
450450

451451
val copy = Baggage.copyWithOverrides(baggage, SentryId("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), 0.2)
452452

453-
assertFalse(copy.isMutable)
454-
assertTrue(copy.isShouldFreeze)
455-
assertEquals("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", copy.traceId)
456-
assertEquals(0.2, copy.sampleRand!!, 0.0001)
457-
assertEquals("75302ac48a024bde9a3b3734a82e36c8", baggage.traceId)
458-
assertEquals(0.1, baggage.sampleRand!!, 0.0001)
459-
}
460-
461-
@Test
462-
fun `copy with overrides creates baggage when source is null`() {
463-
val copy = Baggage.copyWithOverrides(null, SentryId("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), 0.2)
464-
465453
assertTrue(copy.isMutable)
466454
assertFalse(copy.isShouldFreeze)
467455
assertEquals("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", copy.traceId)
468456
assertEquals(0.2, copy.sampleRand!!, 0.0001)
457+
assertEquals("75302ac48a024bde9a3b3734a82e36c8", baggage.traceId)
458+
assertEquals(0.1, baggage.sampleRand!!, 0.0001)
469459
}
470460

471461
@Test

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ class TransactionContextTest {
9999
fun `fromPropagationContextAsRoot copies non trace state`() {
100100
val propagationBaggage = Baggage(NoOpLogger.getInstance())
101101
propagationBaggage.sampleRand = 0.42
102-
propagationBaggage.publicKey = "propagation-public-key"
103102
val propagationContext =
104103
PropagationContext(
105104
SentryId("75302ac48a024bde9a3b3734a82e36c8"),
@@ -110,7 +109,6 @@ class TransactionContextTest {
110109
)
111110
val samplingDecision = TracesSamplingDecision(true, 0.3, true, 0.4)
112111
val transactionContext = TransactionContext("name", "op", samplingDecision)
113-
transactionContext.baggage!!.publicKey = "transaction-public-key"
114112
transactionContext.transactionNameSource = TransactionNameSource.ROUTE
115113
transactionContext.description = "description"
116114
transactionContext.status = SpanStatus.OK
@@ -147,7 +145,6 @@ class TransactionContextTest {
147145
assertEquals(0.4, context.samplingDecision!!.profileSampleRate)
148146
assertEquals(0.42, context.baggage!!.sampleRand)
149147
assertEquals(propagationContext.traceId.toString(), context.baggage!!.traceId)
150-
assertEquals("transaction-public-key", context.baggage!!.publicKey)
151148
assertNull(context.featureFlagBuffer.featureFlags)
152149
}
153150

0 commit comments

Comments
 (0)