Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set client and connection name #1371

Open
reidsunderland opened this issue Jan 22, 2025 · 13 comments
Open

Set client and connection name #1371

reidsunderland opened this issue Jan 22, 2025 · 13 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers Sugar nice to have features... not super important. wishlist would be nice, not pressing for any particular client.

Comments

@reidsunderland
Copy link
Member

In RabbitMQ, you can set both a name for a connection that will show up in light grey underneath the IP address in the RabbitMQ GUI. There's an example of what this looks like and how to set it using Pika here: https://stackoverflow.com/questions/58275505/how-to-set-connection-friendly-name-rabbitmq-python

And it looks like we can do it with the amqp library we are using as well: celery/kombu#1252

It seems easy enough to add here by adding client_properties={'connection_name': 'foo'}:

self.connection = amqp.Connection(host=host,
userid=broker.url.username,
password=unquote(
broker.url.password),
login_method=broker.login_method,
virtual_host=vhost,
ssl=(broker.url.scheme[-1] == 's'))

It would also be nice to try to change the product name we are using. It currently shows up as py-amqp.

Image

Some users using Pika have a better client name:

Image

It would be great if we could show the current Sarracenia version, like we set for the HTTP user agent.

headers = {'user-agent': 'Sarracenia ' + sarracenia.__version__}

I think we can also do this with client_properties, by setting { 'product': 'Sarracenia', 'product_version': sarracenia.__version__, }

https://github.com/celery/py-amqp/blob/b1f9c2e3d10c35601c9453a074bf8ae8dee9dd5b/amqp/connection.py

@reidsunderland reidsunderland added enhancement New feature or request good first issue Good for newcomers Sugar nice to have features... not super important. wishlist would be nice, not pressing for any particular client. labels Jan 22, 2025
@reidsunderland
Copy link
Member Author

I did a quick test, it works:

Image

@reidsunderland
Copy link
Member Author

I'm not quite sure what to put for the connection name.

Ideally it would be configurable, with a default that maybe includes the config name, maybe instance number, username

@petersilva
Copy link
Contributor

petersilva commented Jan 22, 2025

if a give queue/consumer has two connections, should the id include something to tell them apart? "management" vs. "data" or just 1, 2?

@reidsunderland
Copy link
Member Author

we open two channels (one for management, like checking the queue size, and one for getting messages), but they are both under a single connection.

The connection is where this name gets applied. I did a quick search, but don't see a way to give a channel a name. They seem to get assigned numbers (e.g. connection_abc - channel 1, 2, 3, ...)

self.management_channel = self.connection.channel(1)
self.channel = self.connection.channel(2)

Here's an example of how a connection looks. It shows the 2 numbered channels:

Image

@petersilva
Copy link
Contributor

oh... AMQP is so obtuse... channels vs. connections.. I got them confused. There's a reason MQTT is winning. OK so the way things are is good then?

@petersilva
Copy link
Contributor

in MQTT, there are no queues... so we use the queueName to provide the connection-ID. I wonder if just using the queueName for the channel description is a good idea, then you don't need a separate setting, and it is likely to provide good info.

@petersilva
Copy link
Contributor

for something like "for q_...."

@petersilva
Copy link
Contributor

only works for subscribers though... need something else for publishers... hmm...

@petersilva
Copy link
Contributor

We don't set any connection-id in publishers in mqtt. hmm...

@reidsunderland
Copy link
Member Author

One thing that would be awesome to have is contact information, like an email address. It would have to be optional, but if users could set an email address in the config, and we could see it on the broker-side, that would be really useful.

I guess that overlaps a bit with our need/desire to ensure contact information is present in our config files.

@petersilva
Copy link
Contributor

a contact_email would be great!

@petersilva
Copy link
Contributor

@andreleblanc11 noticed someone used a url in the property... so perhaps contact url is a good thing:

maybe call it "contact_url"

@petersilva
Copy link
Contributor

The git url's are for the "product" property... rather than the "connection name" ...

@reidsunderland reidsunderland self-assigned this Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers Sugar nice to have features... not super important. wishlist would be nice, not pressing for any particular client.
Projects
None yet
Development

No branches or pull requests

2 participants