spring-cloud / spring-cloud-stream

Framework for building Event-Driven Microservices
http://cloud.spring.io/spring-cloud-stream
Apache License 2.0
1.01k stars 614 forks source link

Micrometer context propagation does not work in multi-binder scenarios when binder types are the same (e.g., Rabbit and Rabbit) #2901

Closed Toxa45 closed 9 months ago

Toxa45 commented 9 months ago

Good afternoon. When using SteamBridge with RabbitMQ, the traceId of the sender and recipient are different. Here is an example based on what was attached in https://github.com/spring-cloud/spring-cloud-stream/issues/2639, but the traceId are different. https://github.com/Toxa45/TestRabbitTraceId/tree/master/TestRabbitTraceId image I also noticed that this happens when the “environment” is filled. Initially, I made a typo and wrote “environment” - and, to my surprise, everything worked locally.

olegz commented 9 months ago

Hey @Toxa45 I have modified your description since there is no problem with StreamBridge, rather with the fact that you are using multi-binder scenario where you don't really need to. You taking data from the same instance of Rabbit as the one you are sending to. Your configuration should be simplified to

spring:
  cloud:
    function:
      definition: testListener
    stream:
      output-bindings: test
      bindings:
        test-out-0:
          destination: test
          group: test
        testListener-in-0:
          destination: test
          group: test
logging:
  pattern:
    level: "%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]"

management:
  tracing:
    sampling:
      probability: 1

Now, if this was just an academic exercise and your intention is to use multi-binder scenario for some real use case, where the type of the binder (i.e., Rabbit) is the same, than at the moment it is not supported and we'll be planning on adding suport for it for 4.2.

Toxa45 commented 9 months ago

@olegz Good afternoon. When is 4.2 planned to be released? Or maybe there is some kind of temporary solution?

Toxa45 commented 9 months ago

@olegz Good afternoon. The example that I posted is just an example that was transferred from a real project. The binders settings in the example are just to reproduce the error locally. You don’t have binders, so how do you suggest specifying the required host and credentials to connect to rabbit?

spring:
    cloud:
        stream:
            binders:
                rabbit:
                    type: rabbit
                    environment:
                        spring:
                            rabbitmq:
                                password: pass
                                username: username
                                port: 5672
                                virtual-host: /
                                deliveryMode: 2
                                host: RABBIT_HOST