Skip to content

Improve Spring-messaging transaction names and failure recognition #2812

@JonasKunz

Description

@JonasKunz

At the moment messaging transactions are fully handled by the instrumentation of the used underlying messaging technology.
This means that for example Transactions are simply named like Receive message from Topic/Queue XY.

Imo it would be more developer-friendly to do the naming similar to how we do it for spring-web-mvc: We should use the actual entry-method into the user-code as transaction name. Depending on the used messaging technology, these are bean methods annotated with @KafkaListener, @JmsListener or @RabbitListener.

In addition we currently are missing proper failure detection for spring message handlers. Spring catches exceptions thrown by the user-provided messagehandler, meaning that they never reach our messaging-technology instrumentation layer. It would be great to mark the transactions as failed and to record the exception when a handler throws one.

I didn't investiage further, but org.springframework.messaging.handler.invocation.InvocableHandlerMethod#invoke looks like it might be a good universal instrumentation point for recording the method names of handlers registered via the annotations listed above.
However, we need to take care that we do not mess up the naming when listeners are registered programatically.

For the failure/exception detection we should use an instrumentation point which is used for both types of handlers (annotation-based and programatically registered).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions