You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ref(tracing): Check and set mutability of baggage (#5205)
Introduce a third item to our `Baggage` tuple which is a mutability flag. The reason for adding this flag is to set the mutability of the baggage object when we receive one, either from incoming requests or `<meta>` tags in the browser. It's necessary to decide about mutability at this time because the decision depends on the `sentry-trace` header. Since we're lazily populating baggage when it gets sent (propagated), we have to know at that time, if we are allowed to add `sentry-` entries to it, or if we should just pass it along as is. The only way to cover all cases of when we're allowed to make changes is to set the flag at the incoming time and check it at population time.
Specifically, we identify and handle mutability in the following cases:
* Incoming request w/ baggage that contains `sentry-*` items (and possibly 3rd party items):
* At incoming request time (IRT): Parse and store baggage on the span. Set it immutable
* At baggage propagation time (BPT): Propagate baggage
* Incoming request w/o baggage header:
* if `sentry-trace` is present
* IRT: create empty baggage object and set it to immutable
* BPT: propagate baggage
* else,
* IRT: create empty baggage object (to be populated later) and leave it mutable
* BPT: populate, set it immutable, propagate it
* Incoming request with baggage header that only contains 3rd party items: Same as above. In both cases, we propagate the 3rd party baggage.
* Incoming request w/o any of the two headers:
* IRT: create empty baggage object (to be populated later) and leave it mutable
* BPT: populate, set it immutable, propagate it
* No baggage set on the span at BPT: populate, set it immutable, propagate it
Checking for the presence of the `sentry-trace` header is important because if it is present, we know that the trace was already started which means that whatever handler is receiving it, cannot modify baggage anymore. Getting a `sentry-trace` but no `baggage` header, can (and will) for example occur, when the SDK that started the trace does not yet support and propagate baggage.
0 commit comments