Parse sentry-org_id from incoming baggage headers and store the parsed value on TransactionContext for later strict continuation decisions. This task should not enforce strict continuation yet and should not implement full Dynamic Sampling Context parsing or outgoing baggage propagation. This is part of #1016.
The goal is to make the incoming organization ID available to transaction creation while keeping the change behavior-neutral.
Implementation notes
Target file:
sentry-core/src/performance.rs
Implementation:
- Add an internal parsed incoming trace metadata type, for example
struct IncomingTrace { sentry_trace: SentryTrace, org_id: Option<OrganizationId> }.
- Preserve public compatibility for
parse_headers; either keep parse_headers returning Option<SentryTrace> and add a private parse_incoming_trace_headers, or add a distinct helper while leaving parse_headers unchanged.
- Extend
TransactionContext with an internal incoming_org_id: Option<OrganizationId> field.
- Initialize
incoming_org_id to None in constructors except continue_from_headers.
- Update
TransactionContext::continue_from_headers to parse both sentry-trace and baggage.
- Parse baggage minimally:
- scan comma-separated baggage members
- trim whitespace around members
- match only key
sentry-org_id
- parse the value as
OrganizationId
- treat malformed, empty, duplicate-unparseable, or absent values as
None
- Do not parse, preserve, or serialize any other DSC fields.
Tests:
baggage: sentry-org_id=123 is parsed.
- Baggage with unrelated fields before or after
sentry-org_id is parsed.
- Mixed-case
baggage header name is accepted.
- Malformed org IDs are treated as absent.
- No
sentry-trace means the returned context starts a fresh trace and does not carry an incoming org ID.
- Validate with
cargo test -p sentry-core performance.
Parse
sentry-org_idfrom incomingbaggageheaders and store the parsed value onTransactionContextfor later strict continuation decisions. This task should not enforce strict continuation yet and should not implement full Dynamic Sampling Context parsing or outgoing baggage propagation. This is part of #1016.The goal is to make the incoming organization ID available to transaction creation while keeping the change behavior-neutral.
Implementation notes
Target file:
sentry-core/src/performance.rsImplementation:
struct IncomingTrace { sentry_trace: SentryTrace, org_id: Option<OrganizationId> }.parse_headers; either keepparse_headersreturningOption<SentryTrace>and add a privateparse_incoming_trace_headers, or add a distinct helper while leavingparse_headersunchanged.TransactionContextwith an internalincoming_org_id: Option<OrganizationId>field.incoming_org_idtoNonein constructors exceptcontinue_from_headers.TransactionContext::continue_from_headersto parse bothsentry-traceandbaggage.sentry-org_idOrganizationIdNoneTests:
baggage: sentry-org_id=123is parsed.sentry-org_idis parsed.baggageheader name is accepted.sentry-tracemeans the returned context starts a fresh trace and does not carry an incoming org ID.cargo test -p sentry-core performance.