-
Notifications
You must be signed in to change notification settings - Fork 452
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
Allow O(1) get operations for SpanBuilder::attributes [breaking] #799
Allow O(1) get operations for SpanBuilder::attributes [breaking] #799
Conversation
Codecov Report
@@ Coverage Diff @@
## main #799 +/- ##
=====================================
Coverage 69.7% 69.8%
=====================================
Files 109 110 +1
Lines 9045 9060 +15
=====================================
+ Hits 6313 6324 +11
- Misses 2732 2736 +4
Continue to review full report at Codecov.
|
👍 Nice work. Just one request |
…ue iterators/collections.
I've addressed it in an additional commit 👍🏻 |
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.
LGTM. Thanks a lot. This is a great improvement 🎉
@LukeMathWalker @TommyCpp Uping MSRV to 1.55 will likely break compatibility with |
#794 has the full discussion but on the high level, lib writers wants to manipulate the attributes attached on spans and current implementation only supports do it by iterate through the attributes array, which is O(N) On top of that we need to preserve the relative order the insertion so that the when number of the attributes exceed the limits we can trim the last attributes. Combine the requirements we somehow want a OrderMap. We can try to pin the version of There are other places in the PR uses features stabilized after 1.49 but we can probably remove them. |
I see. The spec has some similar issues open, could be worth documenting the relationship between Also worth considering the configuration options for other structs besides |
Closes #794
It changes the type of
SpanBuilder::attributes
fromVec<KeyValue>
toOrderMap
.OrderMap
is a thin wrapper aroundindex_map::IndexMap
that only exposes the methods that preserve the original insertion order, which is what we care about later in the pipeline when enforcing the maximum number of attributes per span.