Skip to content

Commit

Permalink
chore(utils): Update parseBaggageSetMutability docstring (#5657)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad committed Aug 30, 2022
1 parent 51c016f commit aff06e0
Showing 1 changed file with 8 additions and 9 deletions.
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

0 comments on commit aff06e0

Please sign in to comment.