rqueue icon indicating copy to clipboard operation
rqueue copied to clipboard

whether opentelemetry traceId is supported

Open cxc222 opened this issue 8 months ago • 4 comments

How to support OpenTelemetry traceId? I used the OpenTelemetry agent but found the traceId is not correlated.

cxc222 avatar Jun 11 '25 02:06 cxc222

There are two ways to do this

  • We need to add a middleware which will inject the open telemetry and initialise it.
  • Add annotation on the handler method which will inject trace ids.

sonus21 avatar Jun 11 '25 03:06 sonus21

There are two ways to do this

  • We need to add a middleware which will inject the open telemetry and initialise it.
  • Add annotation on the handler method which will inject trace ids.

are there any cases available for reference? thank you very much.

cxc222 avatar Jun 14 '25 09:06 cxc222

Did you check adding @WithSpan on the listener method? It should work in most of the cases, as I'm not sure about your current project setup so I can't comment which annotation should be used in your project.

If nothing works you can add a middleware like its done here and you can create span and end the span in the finally block.

There're many builtin middlewares defined here https://github.com/sonus21/rqueue/tree/master/rqueue-core/src/main/java/com/github/sonus21/rqueue/core/middleware

You can customize one of them or create new one. Once middleware class is created you can register them via SimpleRqueueListenerContainerFactory.setMiddlewares.

https://github.com/sonus21/rqueue/blob/master/docs/message-handling/middleware.md

sonus21 avatar Jun 14 '25 13:06 sonus21

Did you check adding @WithSpan on the listener method? It should work in most of the cases, as I'm not sure about your current project setup so I can't comment which annotation should be used in your project.

If nothing works you can add a middleware like its done here and you can create span and end the span in the finally block.

There're many builtin middlewares defined here https://github.com/sonus21/rqueue/tree/master/rqueue-core/src/main/java/com/github/sonus21/rqueue/core/middleware

You can customize one of them or create new one. Once middleware class is created you can register them via SimpleRqueueListenerContainerFactory.setMiddlewares.

https://github.com/sonus21/rqueue/blob/master/docs/message-handling/middleware.md

Thanks for guiding me. I'll give it a shot.

cxc222 avatar Jun 14 '25 14:06 cxc222