-
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
API design: SpanBuilder::attributes #794
Comments
I image the use case here is to tweak the attributes from a library? With the new Hashmap API maybe we can change it to accept a iterator of the Key value pairs. |
That's exactly the use case: insertion of new attributes (based on the values of existing ones) and manipulation of existing attributes. This is currently done inside a custom |
I think it's a reasonable ask from library developers. I guess another problem using HashMap is it doesn't preserve the order of attributes, which is later used to decide which attributes need to be dropped if the number of the attributes is exceed the limit. If we want to use HashMap inside the |
We could use |
Sounds like we should maybe use some kind of LRU map? |
I think
The tricky thing here is in common use cases users shouldn't read attributes in span builder much before building & evicting. |
It is also true that by postponing eviction we might be exposing users to unnecessary memory pressure - i.e. pushing way more attributes into |
On the other hand, if we evict the attributes in Let's say you want to check if there is a |
I agree with your argument @TommyCpp. |
I have a sketch in #799 👍🏻 |
@LukeMathWalker Could you comment on #1293, as we are effectively re-versing the fix for this issue, along with few others. I don't think you'll be notified on all PRs from this repo, but I think you'd have some say in the proposal, hence tagging! |
I'm no longer on the project where this was an issue, although I can see its value. It's a trade-off for you to manage I guess, between versatility and performance. @cijothomas |
Attributes attached to a
SpanBuilder
are currently stored as aVec<opentelemetry::KeyValue>
- see docs.This makes it impossible to access the value attached to a specific key or to verify that an attribute is present in O(1). It always take O(n), where n is the number of attributes - this can be significant.
Why was a
Vec<KeyValue>
chosen over aHashMap<Key, Value>
?I see it gets later processed into an
EvictedHashMap
whenSpanBuilder
gets converted into aSpan
🤔The text was updated successfully, but these errors were encountered: