Skip to content

Add items and bytes limits to baggage extraction#11265

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit intomasterfrom
bbujon/baggage
May 4, 2026
Merged

Add items and bytes limits to baggage extraction#11265
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit intomasterfrom
bbujon/baggage

Conversation

@PerfectSlayer
Copy link
Copy Markdown
Contributor

@PerfectSlayer PerfectSlayer commented May 4, 2026

What Does This Do

This PR ensure baggage extraction applies baggage items and bytes limits.

Motivation

Keeping too many bagage items or too big baggage items can increase memory usage for the time the related extracted context is active.

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]

Note: Once your PR is ready to merge, add it to the merge queue by commenting /merge. /merge -c cancels the queue request. /merge -f --reason "reason" skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.

@PerfectSlayer PerfectSlayer requested a review from a team as a code owner May 4, 2026 11:31
@PerfectSlayer PerfectSlayer requested review from mtoffl01 and removed request for a team May 4, 2026 11:31
@PerfectSlayer PerfectSlayer added type: enhancement Enhancements and improvements comp: context propagation Trace context propagation tag: security Security related changes type: bug Bug report and fix and removed type: enhancement Enhancements and improvements labels May 4, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8a0f2ed289

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +166 to +167
boolean limitReached = baggage.size() >= maxItems || end > maxBytes;
if (limitReached) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Record baggage extraction truncation metrics

When an incoming baggage header exceeds trace.baggage.max.items or trace.baggage.max.bytes, this new limit branch truncates the extracted baggage but never calls BAGGAGE_METRICS.onBaggageTruncatedByItemLimit() or onBaggageTruncatedByByteLimit(). In those scenarios extract() still reports a successful extraction, so telemetry consumers lose the context_header.truncated signal that injection already emits for the same configured limits.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

@PerfectSlayer PerfectSlayer May 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those metrics are used for context injection, not extraction… and the team in charge of this code part and metrics already ready the patch.

@DataDog DataDog deleted a comment from github-actions Bot May 4, 2026
int kvSeparatorInd = input.indexOf(KEY_VALUE_SEPARATOR);
while (kvSeparatorInd != -1) {
int end = pairSeparatorInd;
boolean limitReached = baggage.size() >= maxItems || end > maxBytes;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw I think that this is an approximation since end works with nb of chars and not bytes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes: byte limit is enforced against String char (UTF-16 code unit) length: exact for ASCII baggage, conservative on memory for multi-byte UTF-8 input.
Using the exact byte limit would have allocated memory which we try to prevent with this fix.

@ericdog
Copy link
Copy Markdown

ericdog commented May 4, 2026

I think you need to rebase from master, there is a missing gitlab stage that is present on master branch now

@amarziali amarziali enabled auto-merge May 4, 2026 12:36
@amarziali amarziali disabled auto-merge May 4, 2026 12:36
@PerfectSlayer
Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented May 4, 2026

View all feedbacks in Devflow UI.

2026-05-04 13:12:27 UTC ℹ️ Start processing command /merge


2026-05-04 13:12:36 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-05-04 13:22:18 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in master is approximately 2h (p90).


2026-05-04 14:41:03 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 16c6a5f into master May 4, 2026
750 of 752 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the bbujon/baggage branch May 4, 2026 14:40
@github-actions github-actions Bot added this to the 1.62.0 milestone May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: context propagation Trace context propagation tag: security Security related changes type: bug Bug report and fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants