Skip to content

chore(utils): Update parseBaggageSetMutability docstring #5657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 30, 2022
Merged
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
17 changes: 8 additions & 9 deletions packages/utils/src/baggage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,15 @@ export function mergeAndSerializeBaggage(incomingBaggage?: Baggage, thirdPartyBa
}

/**
* Helper function that takes a raw baggage string (if available) and the processed sentry-trace header
* data (if available), parses the baggage string and creates a Baggage object
* If there is no baggage string, it will create an empty Baggage object.
* In a second step, this functions determines if the created Baggage object should be set immutable
* to prevent mutation of the Sentry data.
* Helper function that takes a raw baggage value (if available) and the processed sentry-trace header
* data (if available), parses the baggage value and creates a Baggage object. If there is no baggage
* value, it will create an empty Baggage object.
*
* Extracted this logic to a function because it's duplicated in a lot of places.
* In a second step, this functions determines if the created Baggage object should be set immutable
* to prevent mutation of the Sentry data. It does this by looking at the processed sentry-trace header.
*
* @param rawBaggageValue
* @param sentryTraceHeader
* @param rawBaggageValue baggage value from header
* @param sentryTraceHeader processed Sentry trace header returned from `extractTraceparentData`
*/
export function parseBaggageSetMutability(
rawBaggageValue: HttpHeaderValue | false | undefined,
Expand All @@ -187,7 +186,7 @@ export function parseBaggageSetMutability(
// this SDK is the head of the trace and thus we still permit mutation at this time.
// There is one exception though, which is that we get a baggage-header with `sentry-`
// items but NO sentry-trace header. In this case we also set the baggage immutable for now
// but if smoething like this would ever happen, we should revisit this and determine
// but if something like this would ever happen, we should revisit this and determine
// what this would actually mean for the trace (i.e. is this SDK the head?, what happened
// before that we don't have a sentry-trace header?, etc)
(sentryTraceHeader || !isSentryBaggageEmpty(baggage)) && setBaggageImmutable(baggage);
Expand Down