wolph / python-statsd

Python Client for the Etsy NodeJS Statsd Server
http://readthedocs.org/docs/python-statsd/en/latest/
BSD 3-Clause "New" or "Revised" License
110 stars 39 forks source link

support for connecting to statsd via tcp #36

Closed WestleyArgentum closed 9 years ago

WestleyArgentum commented 9 years ago

Statsd can be configured to accept messages over tcp (instead of udp)

Would this be easy to add?

wolph commented 9 years ago

The basic principle would be trivial to implement. Simply pass SOCK_STREAM instead of SOCK_DGRAM to the socket() call here: https://github.com/WoLpH/python-statsd/blob/master/statsd/connection.py#L41

But generally you really don't want to. TCP has loads of overhead due to making connections, keeping them open. Handling disconnects, handling timeouts, etc... For development it might be convenient to have but I would strongly recommend against using it for production.

With UDP if the server is down/unavailable/broken/whatever the library will still work without any problems. With TCP it will hang until it times out effectively making the measuring a slow/heavy process.