Commit 4f11aac
fix(baggage): Ensure deterministic ordering with sentry members first
The Baggage.String() method was using non-deterministic map iteration,
making it impossible to guarantee that sentry- prefixed members would
appear first in the serialized baggage string. This violated the W3C
Baggage spec requirement that critical members should appear first to
survive truncation when size limits are exceeded.
This fix sorts baggage keys deterministically, placing all sentry-
prefixed keys first (in alphabetical order), followed by other keys
(also alphabetically). This ensures:
1. Sentry distributed tracing members always appear first
2. The ordering is consistent across all invocations
3. The test 'sentry members appear before third party members' no
longer exhibits flaky behavior
Co-Authored-By: Claude Sonnet 4.5 <noreply@example.com>1 parent 2ebe6a5 commit 4f11aac
1 file changed
Lines changed: 29 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
591 | 592 | | |
592 | 593 | | |
593 | 594 | | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
594 | 600 | | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
595 | 622 | | |
596 | | - | |
| 623 | + | |
| 624 | + | |
597 | 625 | | |
598 | 626 | | |
599 | 627 | | |
| |||
0 commit comments