spring-cloud / spring-cloud-commons

Common classes used in different Spring Cloud implementations
Apache License 2.0
701 stars 697 forks source link

Micrometer traceID/spanID is not propagating when using different virtual-host for binders #1341

Closed KeerthigaMargesan4 closed 1 month ago

KeerthigaMargesan4 commented 5 months ago

Attached my spring boot 3 application with rabbitMQ and micrometer tracing, its a spring web application. Dummy.zip

Here traceID / spanID is not propagating to other threads for the events listeners. For the first event I am getting traceID/spanID but for subsequent event no tracing info. On analysis found that using different virtual-host in the binders for the queues blocks the tracing observation.

Log for event with Binder and specific virtual-cost (guest)

{"timestamp":"2024-02-27 13:34:26.638","level":"INFO","thread":"test-event-5","mdc":{"traceId":"65dd978a1c793d43931890ba4748e045","spanId":"931890ba4748e045"},"logger":"check.TestEventListener","message":"Handling handlerWithBinder with content","context":"default"} {"timestamp":"2024-02-27 13:34:33.075","level":"INFO","thread":"test-event-3","logger":"check.TestEventListener","message":"Handling handlerWithBinder with content","context":"default"}

Log for event with Binder and common virtual-cost (application)

{"timestamp":"2024-02-27 13:26:44.835","level":"INFO","thread":"test-event-4","mdc":{"traceId":"65dd95bc7e86db9acb0ce5ac20ed8800","spanId":"e00226a44cb852f2"},"logger":"check.TestEventListener","message":"Handling handlerWithBinder with content","context":"default"} {"timestamp":"2024-02-27 13:26:53.533","level":"INFO","thread":"test-event-10","mdc":{"traceId":"65dd95c52db8f53125d1701f91191fb3","spanId":"25d1701f91191fb3"},"logger":"check.TestEventListener","message":"Handling handlerWithBinder with content","context":"default"}

Note: if environment.spring.rabbitmq.virtual-host: guest is removed in application.yml then MDC info gets populated in the log.

OlgaMaciaszek commented 1 month ago

Hello, @KeerthigaMargesan4. Please report any Micrometer-related issues in https://github.com/micrometer-metrics/micrometer.