ruby-amqp / hutch

A system for processing messages from RabbitMQ.
https://gocardless.com/blog/hutch-inter-service-communication-with-rabbitmq/
MIT License
855 stars 137 forks source link

Client properties #398

Closed sharshenov closed 4 months ago

sharshenov commented 4 months ago

Thank you for this project! :heart:

I've noticed an opportunity to enhance observability from the broker's perspective.

Firstly, introducing a feature to set a human-friendly connection name would greatly improve the ability to distinguish connections easily.

Secondly, providing additional information in client properties could be useful in identifying issues with applications, such as the application version.

With this pull request, I propose adding two additional configuration options:

  1. connection_name - to set the connection name conveniently. It can be easily controlled with the HUTCH_CONNECTION_NAME environment variable, requiring no explicit configuration.
  2. mq_client_properties - to manage all client properties, including the connection_name.

    Hutch::Config.set :mq_client_properties,
                      connection_name: 'human-friendly-consumer-name',
                      product: 'SomethingCool',
                      version: 'commit-sha',
                      information: 'http://example.com/repo/commits/commit-sha'
    Before ![Screenshot from 2024-05-06 20-27-51](https://github.com/ruby-amqp/hutch/assets/1262244/b613a168-882a-4a68-9de2-7502c9004789) ![Screenshot from 2024-05-06 20-46-05](https://github.com/ruby-amqp/hutch/assets/1262244/80b8e7ab-d0b7-4dea-9609-a8fa5ac469dc)

After ![Screenshot from 2024-05-06 20-55-33](https://github.com/ruby-amqp/hutch/assets/1262244/a12d4c7e-2c51-43ca-9da8-1d35647b612d) ![Screenshot from 2024-05-06 20-53-58](https://github.com/ruby-amqp/hutch/assets/1262244/2779b7c8-8b66-465e-8687-fc259486bfdc)
sharshenov commented 4 months ago

The test failure is not relevant to the change. I have no permissions to restart the build.

michaelklishin commented 4 months ago

Exposing client-provided connection name is definitely a good idea. Thank you for contributing!