-
Notifications
You must be signed in to change notification settings - Fork 657
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
Span should have a getter for attributes #715
Comments
I can take this on if help is still needed. |
For this issue do all instances of attributes.get() need to be refractored to the new getter method (i.e. span.get_attribute(key)? |
Would this be in the main OTel API? Asking cause we don't have that one in the other languages (they do exist in the SDK though). |
No right now just implementing in the sdk but I can add it ton the API if need be |
Tthe main problem that was being captured by this issue is that many instrumentations are calling out the a span's |
It doesn't necessarily needed to be added to the API, but it does requires the need for an SDK-specific noop span that returns nothing for the getter. That said I support more explicitly providing a "Span" object in the API, and having an attribute getter with that. |
@aravinsiva, I think you discussed this (or was it something different?) in the Spec SIG last week. Did you come to any conclusion if this should be added to the Spec API? |
It was something different. Last week in the spec SIG I was talking about default span attributes in OT-js. If you feel like this is something that should be brought up in the next spec SIG I would be happy to do that. |
Does the existence of Also, wouldn't this problem occur for all api level properties of the span? (events, links, spankind) |
After speaking to the specification SIG it seems as though the API was designed to be write only it and this is intentional. As a result we may need to develop another approach to solving the this issue. As @lzchen mentioned this is something that also occurs with events, links and spankind attributes. Since this does not seem to be getting raised to the spec level we may need to detemermined another approach to solving this issue. @codeboten suggested maybe looking for all instances of the attributes value being accessed and seeing if it exists. This is however a likely bad solution which won't enforce this down the line. As a result is there any solution to this issue as of right now? If so I would love to hear your guy's thoughts. |
I think this would be the easiest, least intrusive solution. Even though "get" is not defined in the API specs, the issue seems language specific, and some other languages don't seem to be using a no-op span. |
Please reassign bug as internship is concluding |
I think there's a way to resolve this without changing the spec. Namely:
I can take the issue, if there's consensus on the approach. @codeboten? |
Isn't the no-op span in the api?
I'm not sure I understand the reasoning for this. Are you planning to move the no-op span implementation to the sdk? |
Would this address the original issue of an attribute error though? Replacing tracer.NoopSpan with trace.sdk.NoopSpan would only cover the cases where we use the defaultspan in the sdk (like if the span is not sampled). But for cases like the instrumentations, in which we only take a dependency on the api, users do not have to use trace.sdk...., in which we would still run into the problem of accessing span attributes that possibly might not exist. |
@lzchen I just did a scan through the code. No instrumentation is dependent on the .attributes method. The value is used in:
What instrumentations depends on retrieving attributes? I'd argue that's an anti-pattern, as the API explicitly states that shouldn't be provided, and instrumentations should only work with the API methods. |
Yes I was just using an example. But I believe what you are saying is true about it being an anti-pattern, they should be using the api methods provided, so whoever creates them should be mindful of that. I am fine with the proposed idea. |
@toumorokoshi I just wanted to confirm whether it has finally been decided to add a getter in sdk to access span attributes as it relates to the issue I am looking into mentioned above by lzchen. I am not sure whether to make the attributes harder to access or simply rely on the docs. |
@shovnik getters in the SDK should be provided, as it's part of the spec. Can you clarify on the work you're doing, and how that affects accessibility of attributes? |
I was just trying to decide the best way to make the attributes inaccessible or if I should rely on docs. Since there currently wasn't a getter, I figured making the attributes private in some way right now would make them completely inaccessible. As suggested, I will attend this week's SIG to see if there is an agreed upon standard approach for controlling access rather than treating each future case individually. |
What is the motivation for making the attributes private? Again according the spec "attributes" should be accessible in the SDK. |
Instrumentation should never access the attributes directly, the SDK having access to attributes is fine. Closing this issue |
Currently there are multiple places in the code that make the assumption that a
Span
has anattributes
attribute, this is not always the case.The solution could be to implement an attributes property on the Span interface, or we could implement a separate getter method.
The text was updated successfully, but these errors were encountered: