Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Baggage improvements #2284

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fraillt
Copy link
Contributor

@fraillt fraillt commented Nov 7, 2024

Changes

Improve few things:

  • BaggageExt::with_baggage now "clone" baggage, instead of iterate+collect.
  • Baggage::insert_with_metadata (used everywhere) should be a bit faster, as it had redundant calculations:
    • access hashmap once (before it was twice)
    • calculate entry content length once (before it was three times, although it's so trivial that probably it's not noticeable anyway)
  • updated incorrect comment on Baggage::iter

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@fraillt fraillt requested a review from a team as a code owner November 7, 2024 08:14
Copy link

linux-foundation-easycla bot commented Nov 7, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

Attention: Patch coverage is 68.42105% with 12 lines in your changes missing coverage. Please review.

Project coverage is 79.6%. Comparing base (45ed2e0) to head (a20d014).

Files with missing lines Patch % Lines
opentelemetry/src/baggage.rs 68.4% 12 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #2284     +/-   ##
=======================================
- Coverage   79.6%   79.6%   -0.1%     
=======================================
  Files        123     123             
  Lines      21263   21255      -8     
=======================================
- Hits       16938   16926     -12     
- Misses      4325    4329      +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

None
if !key.as_str().is_ascii() {
return None;
}
Copy link
Member

Choose a reason for hiding this comment

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

I understand this is the existing code, but baggage specs only allow for the printable ASCII characters. Probably, good to also check for control characters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how to fix that in efficient way, so I would prefer to leave this to someone more competent.

Some(occupied_entry.insert((value, metadata)))
}
Entry::Vacant(vacant_entry) => {
if entries_count == MAX_KEY_VALUE_PAIRS {
Copy link
Member

Choose a reason for hiding this comment

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

Though this is existing code, the limit is 64 as per the specs, while we use 180 - good to update that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I can updated that, also I noticed that MAX_BYTES_FOR_ONE_PAIR is also removed form spec, so I'll remove this as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants