-
Couldn't load subscription status.
- Fork 586
feat: add an Iterator for opentelemetry::trace::TraceState key-value pairs #3164
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3164 +/- ##
=====================================
Coverage 80.8% 80.9%
=====================================
Files 128 128
Lines 23090 23136 +46
=====================================
+ Hits 18676 18722 +46
Misses 4414 4414 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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:
opentelemetry-rust/opentelemetry-sdk/src/resource/mod.rs
Lines 245 to 252 in 3b2f751
| 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()) | |
| } | |
| } |
opentelemetry-rust/opentelemetry/src/baggage.rs
Lines 254 to 261 in 3b2f751
| 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()) | |
| } | |
| } |
Changes
Implement
IntoIteratorforTraceStateby relying into theTraceStateIteriterator.Notes
Now the only way to extract the different entries of the TraceState is using the
header()orheader_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
CHANGELOG.mdfiles updated for non-trivial, user-facing changes