Skip to content

Conversation

@iunanua
Copy link
Contributor

@iunanua iunanua commented Sep 12, 2025

Changes

Implement IntoIterator for TraceState by relying into the TraceStateIter iterator.

Notes

Now the only way to extract the different entries of the TraceState is using the header() or header_delimited() methods, making it impossible to avoid allocations.
That's why providing an iterator can be valuable in certain cases where it's necessary to know the TraceState entries while avoiding serialization.

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)

@iunanua iunanua requested a review from a team as a code owner September 12, 2025 15:29
@codecov
Copy link

codecov bot commented Sep 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.8%. Comparing base (c54d2b8) to head (60feefa).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #3164   +/-   ##
=====================================
  Coverage   80.7%   80.8%           
=====================================
  Files        128     128           
  Lines      23243   23289   +46     
=====================================
+ Hits       18775   18821   +46     
  Misses      4468    4468           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@scottgerring scottgerring left a comment

Choose a reason for hiding this comment

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

Hey @iunanua thanks for the contribution, and sorry for the slow turnaround!

This LGTM and provides a clear perf improvement when needed; I also note there is no other way to do this from outside the crate, and it extends a similar pattern already present for Baggage and the Resource itself:

impl<'a> IntoIterator for &'a Resource {
type Item = (&'a Key, &'a Value);
type IntoIter = Iter<'a>;
fn into_iter(self) -> Self::IntoIter {
Iter(self.inner.attrs.iter())
}
}

impl<'a> IntoIterator for &'a Baggage {
type Item = (&'a Key, &'a (StringValue, BaggageMetadata));
type IntoIter = Iter<'a>;
fn into_iter(self) -> Self::IntoIter {
Iter(self.inner.iter())
}
}

@cijothomas cijothomas merged commit b54fa84 into open-telemetry:main Oct 31, 2025
26 of 27 checks passed
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.

4 participants