-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
GH-3528: Improving Observability in Asynchronous Processing #3558
Conversation
…ssing Fixes: spring-projects#3528 spring-projects#3528 - Improve spring-kafka observability for failures in async consumer tasks when listener methods return CompletableFuture<?> or Mono<?> and throw errors during async execution - Refactoring code in KafkaMessageListenerContainer and MessagingMessageListenerAdapter around observability - Adding tests to verify - Add @nullable annotations to relevant methods for better null safety
catch (RuntimeException e) { | ||
failureTimer(sample, cRecord); | ||
recordInterceptAfter(cRecord, e); | ||
if (!(this.listener instanceof MessagingMessageListenerAdapter<?, ?>)) { |
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 wonder if for consistency this condition has also to be against RecordMessagingMessageListenerAdapter
...
} | ||
} | ||
finally { | ||
if (!(this.listener instanceof MessagingMessageListenerAdapter<?, ?>)) { |
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.
DITTO
this.logger.warn("Container 'Acknowledgment' must be async ack for Mono<?> return type " + | ||
"(or Kotlin suspend function); otherwise the container will ack the message immediately"); | ||
} | ||
result = mono.toFuture(); |
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.
This is not OK to re-assign method argument.
I don't remember SonarCube rule, but we definitely must not override them.
So, you have to introduce internal CompletableFuture<?>
variable and deal with it instead.
@@ -870,6 +899,10 @@ private boolean rawByParameterIsType(Type parameterType, Type type) { | |||
return parameterType instanceof ParameterizedType pType && pType.getRawType().equals(type); | |||
} | |||
|
|||
public void setObservationRegistry(ObservationRegistry observationRegistry) { |
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 setter is in wrong place.
Has to be somewhere after ctor with the rest of setters.
And the method might deserve JavaDoc since it is public
.
…bleFuture, Mono)
Fixes: #3528
#3528