Skip to content

Commit aad4429

Browse files
committed
modify Span.getBaggage() to only mutate when flag allows it
1 parent 1446996 commit aad4429

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

packages/tracing/src/span.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
createBaggage,
66
dropUndefinedKeys,
77
isBaggageEmpty,
8-
isSentryBaggageEmpty,
8+
isBaggageFrozen,
99
setBaggageValue,
1010
timestampWithMs,
1111
uuid4,
@@ -313,10 +313,8 @@ export class Span implements SpanInterface {
313313
public getBaggage(): Baggage | undefined {
314314
const existingBaggage = this.transaction && this.transaction.metadata.baggage;
315315

316-
const finalBaggage =
317-
!existingBaggage || isSentryBaggageEmpty(existingBaggage)
318-
? this._getBaggageWithSentryValues(existingBaggage)
319-
: existingBaggage;
316+
const canModifyBaggage = !(existingBaggage && isBaggageFrozen(existingBaggage));
317+
const finalBaggage = canModifyBaggage ? this._getBaggageWithSentryValues(existingBaggage) : existingBaggage;
320318

321319
return isBaggageEmpty(finalBaggage) ? undefined : finalBaggage;
322320
}

packages/utils/src/baggage.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ export function mergeAndSerializeBaggage(incomingBaggage?: Baggage, headerBaggag
154154
* @param rawBaggageString
155155
* @param traceparentData
156156
*/
157-
// parseBaggagePlusMutability
158157
export function parseAndFreezeBaggageIfNecessary(
159158
rawBaggageString: string | false | undefined | null,
160159
traceparentData: TraceparentData | string | false | undefined | null,

0 commit comments

Comments
 (0)