-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
For spring-kafka, the instrumentation closes the span to early. It closes the span in the failure method of the record interceptor, meant for handling listener level errors. But, when an error is handled, the error is also passed to the container level error handler, known as the CommonErrorHandler. The container level error handler is invoked after the listener level error handler. So the container level error handler never is part of the span.
This makes it hard to detect errors reliably in the traces when using container level error handling.
With Kafka 2.8 (which is closing in on its 4 year anniversary), the afterRecord method was added. This method is invoked after the error handler handled the record. So shifting closing the span from the failure to the afterRecord method would integrate the container level error handler into the span.
However: This might be breaking, as the afterRecord function is not available in 2.7, which is the originally supported version. Completely moving this functionality would mean that any span for Kafka < 2.8 would never be closed again. So either we'd need a concept to detect the Kafka version in use and conditionally close the span, or drop support for 2.7.
Is there any strategy to do such a change? And what would be more desirable?
Disclosure: There is another issue opened for this, issue 12595, which was closed due to inactivities.