-
Notifications
You must be signed in to change notification settings - Fork 525
Remove de-duping of attribute keys #1098
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
Comments
I like the intention but have another suggestion if others don't find it palatable. You're pointing out this case: impl From<&[KeyValue]> for AttributeSet The root issue is that we want First step: let's assume we can remove Next, let's also assume the common case that the keys themselves are known at compile time. This means we could have some new type to represent something like Then, we can produce an iterator of I know it's a bit hand-wavy, but I think we could do better in the API at composing key/value pairs in general, with the compiler doing the checking for dups of keys in the cases where all the keys are known at compile time anyway. |
Might have to retract the original idea of removing deduping in the API/SDK due to uniqueness being a must outlined here in the spec. Instead, maybe we make it a requirement for users to pass in de-duped attribute keys into the api. Your idea sounds interesting. @MadVikingGod is this along the lines of what you were referring to Go was trying to implement with fixed array key names known at compile time? |
The spec allows flexibility there. We could do de-dup in the exporter thread, so it won't affect hot path performance. |
@shaun-cox I like your plan (except for the type alias, which IMO usually just make the code harder to understand). I wonder if it is possible to write a |
#1989 Already addresses this by avoiding de-dup cost in hot path, and punishing only those users who do have duplicates. Keeping the issue open, as we don't have tests to prove this! |
Uh oh!
There was an error while loading. Please reload this page.
In the current metrics SDK implementation, attribute sets with entries that have the same keys are de-duped. The "first" unique key is taken and the rest is dropped. This behavior is not fully defined in the spec so it is up to languages to decide the specific implementation. De-duping does not make sense for a couple of reasons:
seen
hashmap.I ran 2 benchmark tests demonstrating this, the first
Counter/AddUniqueAttr
makes a call to add with 1million unique keys and the seconds makes a call to add with 1 million of the same keys.With de-duping:
Without de-duping:
Of course de-duping will have tremendous time improvements for duplicate attributes but this is probably not worth the overhead of additional time added with non-duplicate attributes.
Thoughts?
The text was updated successfully, but these errors were encountered: