-
Notifications
You must be signed in to change notification settings - Fork 881
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
Port opentelemetry-annotations-1.0 to Instrumenter API #3738
Conversation
Looks like |
beab34c
to
c0e1522
Compare
/easycla |
1 similar comment
/easycla |
...a/io/opentelemetry/instrumentation/api/annotation/support/MethodSpanAttributesExtractor.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
String[] attributeNames = parameterAttributeNamesExtractor.extract(method, parameters); | ||
if (attributeNames == null || attributeNames.length != parameters.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can attributeNames be null? There are a few more null checks, if you can remove unnecessary ones it's good - we avoid them to make the code easier to read for someone that isn't familiar with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The definition of the functional interface allows for it, null
indicating that the method has no parameters to map to attributes: https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation-api-annotation-support/src/main/java/io/opentelemetry/instrumentation/api/annotation/support/ParameterAttributeNamesExtractor.java#L26
I could change that to specify returning an empty array if preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confusingly, I think @Nullable String[]
means a non-null array of nullable strings, while String @Nullable []
means a nullable array of non-null strings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's terrifying. I do defensively check for either the array being null or each element being null, so would that be @Nullable String @Nullable []
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll review the two implementations to see if it's possible that either will return null
, if not I can change the annotation. Is it still worth having the defensive check even if the interface states that it shouldn't be null
? I hate the idea of a bug in instrumentation leading to errors at runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @anuraaga's point is that ParameterAttributeNamesExtractor.extract() returns @Nullable String[]
, so you don't need to check if the array is null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, so if the array itself can't be null (and that does seem to be the case) then the null check is unnecessary and I can leave the annotations as they are. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are (slowly) rolling out NullAway checking, which will hopefully help (or maybe add to?) some of the confusion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(also, I could be wrong about how NullAway interprets @Nullable String[]
, my assumption is based on how Checker Framework works, it will be good to get confirmation here from @anuraaga)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chatted with @anuraaga, NullAway (luckily) does not annotate the contents of the array (like the more powerful, but infinitely more confusing Checker Framework), so @Nullable String[]
means what you thought it meant (Nullable applies to the array, not to the strings). Sorry for the confusion.
...c/test/groovy/io/opentelemetry/instrumentation/api/annotation/support/MethodCacheTest.groovy
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Thanks!
...ctor-3.1/library/src/main/java/io/opentelemetry/instrumentation/reactor/TracingOperator.java
Show resolved
Hide resolved
...in/java/io/opentelemetry/javaagent/instrumentation/otelannotations/WithSpanInstrumenter.java
Outdated
Show resolved
Hide resolved
Will try to address tonight. Work has been a bit insane this week. 😅 |
bb52b2e
to
6c36c97
Compare
thx ❤️ |
Ports the
opentelemetry-annotations-1.0
project to using Instrumenter API in the tracing aspect.Refactors some of the attribute binding code under the
MethodSpanAttributesExtractor
class. Removes the no-longer-usedAsyncSpanEndStrategy
/AsyncSpanEndStrategies
implementations.