-
Notifications
You must be signed in to change notification settings - Fork 864
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
Proposal: Remove AttributeValue class and implement attribute value type-safety with a type-indicating Key. #1580
Comments
I like this idea since the API looks nicer in general. But just for clarity, can you describe why the allocations at runtime are different? Methods like |
For longs, doubles and booleans, yes, the number of allocations is identical, assuming that you've statically pre-allocated your keys. For Strings, though, we have one less allocation, since we don't need to wrap the String in an additional AttributeValue wrapper. This analysis assumes the same type of The big win is the fact that you don't have to wrap String values another time, and you can statically pre-allocate your keys. |
Yeah but #1500 does that without replacing anything - which reading further in the issue you mention explicitly I realize :) Pretty sure we're on the same page but just wanted to make sure they're technically somewhat independent improvements. |
We're on the same page. I think this makes for a slightly nicer API, so I thought I'd at least write up the proposal. :) |
+1 from me, the current API is a bit clunky from a developer experience perspective |
If people are in favor of this issue, please put a 👍 on the PR itself, so we can track interest. |
I like the idea of having a typed key and not having to construct wrappers. Something to consider is adding a construct of a mapper or serializer as a way to deconstruct complex objects outside of the critical path. For example applying a |
Note: a very small demo of this here: #1598 |
check out the most recent commit which shows how this could work. |
This proposal seems to have general approval from @anuraaga , @trask , @tylerbenson (and me), as well as @kenfinnigan . I will go ahead and do the work to make this into a real PR that changes our Attributes to use this pattern. @bogdandrutu @carlosalberto If you disagree with this approach, please speak up ASAP, as it will be a significant change to the APIs (and a significant amount of work to make it happen). |
Is your feature request related to a problem? Please describe.
Describe the solution you'd like
Rather than provide the type-safe wrapper the value side of the attribute, I propose to make the type safety be enforced by providing type-information on the key side. The API would look something like (for the
Span
interface):As mentioned above, this would have the significant allocation advantage of not needing to do any extra allocations at runtime for the values of the attributes, at least for the String valued attributes (which make up the majority of our semantic attributes). The implementation would probably need to wrap the primitives in boxed versions in the storage, so there would be a net zero gain in runtime allocations for the 3 primitive-typed values [again, assuming the keys are statically pre-defined, either in the instrumentation, or in the API's semantic attribute definitions].
A version of this solution was prototyped in this PR: #1097
Describe alternatives you've considered
Several other alternatives have been prototyped and proposed:
AttributeValue
from the public interface. #1081Additional context
This change would be a significant API-breaking change, and would be hard to retrofit post GA. It could be done as an API addition, but would then have the significant downside of having duplicated Attribute management APIs and semantic conventions. Hence, I have marked this issue as required-for-ga, because I think it could only feasibly be done before then.
The text was updated successfully, but these errors were encountered: