Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Convert AttributesExtractor to interface #4363

Merged
merged 1 commit into from
Oct 14, 2021

Conversation

iNikem
Copy link
Contributor

@iNikem iNikem commented Oct 13, 2021

Fixes #3131

@@ -45,8 +45,7 @@ protected abstract void onEnd(
* Sets the {@code value} with the given {@code key} to the {@link AttributesBuilder} if {@code
* value} is not {@code null}.
*/
protected static <T> void set(
AttributesBuilder attributes, AttributeKey<T> key, @Nullable T value) {
default <T> void set(AttributesBuilder attributes, AttributeKey<T> key, @Nullable T value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since set isn't really part of the contract of AttributesExtractor, we should keep them off the method even as defaults. I'm thinking the use case of "fill attribute if available" is so common that it's fine to add the @Nullable annotation in the API and consider it "correct usage". So easiest is probably to rely on the implementation detail that put can be called directly, and I can work on that in the SDK to formalize it.

Can be another PR but we should do it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkwatson explicitly told me on Slack not to rely on null-checking of the put :) But if that gets changed in SDK/API, I will be happy to remove this method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say either rely on it, or move to an internal class - I guess one of the motivations of the change is to make this interface stable :) I don't think the set method can be part of that.

@iNikem iNikem merged commit efddb72 into open-telemetry:main Oct 14, 2021
@iNikem iNikem deleted the attributes-interface branch October 14, 2021 05:36
RashmiRam pushed a commit to RashmiRam/opentelemetry-auto-instr-java that referenced this pull request May 23, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should AttributesExtractor be an interface?
4 participants