Cue / scales

scales - Metrics for Python
Apache License 2.0
920 stars 73 forks source link

Usage within multiprocess environment (like gunicorn) #34

Open jonathanq opened 9 years ago

jonathanq commented 9 years ago

Is there any way to use this library within a multiprocess environment, like when run with Gunicorn (with workers > 1).

Currently each process will collect metrics - and if you want to expose them with Flask statsHandler, it will fail to bind due to all using the same port. This can be disabled or fixed by doing your own stats handler.

However the metrics which are gathered would be per-process. If you enable the graphite writer, each process will write out metrics with the same hostname and then clobber the other processes.

Is there a way around this?

Only (quick) idea I have come up with is using PID of each process to uniquely prefix the metrics. But then when a process is restarted, it will cause lots of extra data to be written on Graphite server.

I am looking into using the gunicorn hooks as well - but wanted to check here first if this is something already solved?

PeterScott commented 9 years ago

There is no built-in support for anything like this, I'm afraid.