-
Notifications
You must be signed in to change notification settings - Fork 851
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
from the public interface.
#1081
Comments
I'd be fine with hiding // setAttributes(AttributeValue... atrs);
span.setAttributes(strAttr, longAttr, doubAttr, boolAttr); |
I'm a big +1 for this proposal from auto-instrumentation perspective, because then we wouldn't need to bridge this class, which is not very efficient: |
Unfortunately, the |
Right, I just forgot we don't have it like that (have been reading so much proto stuff lately here). So definitely I'm up for removing it. |
I am ok-ish to remove this, my reasons to not remove it is the AttributeValue is used in a lot of other places like events, links, resource, spans. So you will have to have a lot of setters for all the possible values. Before making a final decision would like to build a small prototype of how adding events/links/resources will look like. |
@Oberon00 any suggestions on what to do with the Span Links and Events APIs with this proposal? Would you replace with an |
No, if we find we have to do that, I'd rather stay with the current design. I would have suggested adding all overloads. Maybe we can find some design that allows |
I'm working on prototyping how this would look for Events and Links. So far, it feels pretty decent. I'll put in a draft PR when it's a little more ready. |
Keep in mind that AttributeValue is used in: We need to cover all these cases. Also it is very likely will need to add support for Array (already in the specs) and probably Map in the future. |
Oh, I know. :) I've been poring over the 100s of usages of AttributeValue over the past couple days. This will be a pretty big change, if we want to go forward with it. |
After spending a couple of days exploring a couple of different options, I think that if we want to do this (and, I personally think it would be a good thing to clean up), then I think we should do some larger-scale API cleanup that will make remove AttributeValue much more tractable. I think this should include the API change to a type-safe key approach like was demonstrated in #1097, to support more fluent application of semantic attributes.
If we feel like this is a worthwhile pre-GA API rework, then it should be broken up into a bunch of smaller PRs, with the removal of So, my proposal is that we re-work all of the Span attributes APIs to be consistent and simpler. |
Hey @jkwatson On 1) and 2): I remember we used to have I personally like having overloads for simple usage, e.g. Also, observe that Around 3) I think our goal so far has been to have immutable classes (aside of Now, I have two questions:
[1] https://github.com/open-telemetry/opentelemetry-java/pull/81/files |
I think |
With regards to the immutability, we could easily provide builders for these classes, including the Attributes implementation, so the actual classes were immutable. For me, our current API is very strange. We have these 2 interfaces, but no way to create instances of them. There are different ways of creating Resources, Spans, Links, Events, etc, and we're lacking consistency, which makes the API a bit surprising to use. I'm very aware that it's late in the game, so maybe we need to start thinking about a 2.0 API, which would make a strongly consistent and discoverable API for these attribute-driven features. |
I've got some other ideas on how to approach this as a contrib module, so we can prototype API changes before making them part of the core. I'll be doing some exploratory work the next couple days to see if it would work. |
For anyone interested in contributing/commenting/helping, I've opened up a draft PR where I'll be pushing my exploratory work in a contrib module: #1130 |
The main idea behind having these interfaces is to support lazy initialization for the fields (especially for the attributes part) in these objects. As an example someone may write their own implementation of the Event that calculates the attributes only if the Span is recording + does that async if a batch processor is used. |
Happy to support that in a different way, but I think it is a useful think for example I know that in Google they had z-pages enable and all rpc spans were always recording all the events - some were sampled and exporter some just created and recording things and accessed only if someone goes to the z-page |
So which things can you delay-calculate anyway? Wouldn't that mean keeping around references to objects that would otherwise be garbage-collected after the RPC request is handled to instead live until the span is exported? Checking for IsRecorded is possible without any lazy events, so this concerns only tail sampling, which we don't support. See my comment at open-telemetry/opentelemetry-specification#533 (comment):
|
I've got 3 different options prototyped for adding Links over in that PR if people are interested in taking a look. I assume that Events options will end up looking very similar. |
closed via #1631 |
The class
io.opentelemetry.common.AttributeValue
seems a more cumbersome alternative to use over thesetAttribute
overloads for the particular attribute types. It also is rather complicated (e.g., introduces possibilities fornull
even for primitives). Thus, IMHO it would be best to make this class a private implementation detail in the SDK, instead of a public interface in the API.The text was updated successfully, but these errors were encountered: