Python module for sending metrics to Graphite over UDP.
- Simple module-level interface, can be configured by one module and that configuration will be reused across an application importing it
- Uses python-socketcache to minimise DNS lookups and creating new socket objects for minimum performance impact on the application
- Supports a debug mode where metric messages are logged and not sent
- Logs messages for network errors instead of blowing up
import graphiteudp
# By default, sends metrics to localhost:2003 with no prefix.
graphiteudp.init()
graphiteudp.send("foo", 1)
# Send to a specific host, add a prefix, and log messages instead of sending them.
graphiteudp.init("graphite.example.com", prefix = "myapp", debug = True)
# Generates log message: DEBUG 'myapp.bar.monkey 123.000000 1354307985\n' -> ('graphite.example.com', 2003)
graphiteudp.send("bar.monkey", 123)import graphiteudp
graphiteudp.init(...)
import barimport graphiteudp
graphiteudp.send("bar.things", 1)import graphiteudp
g = graphiteudp.GraphiteUDPClient(...)
g.send("foo", 1)Unknown.
- Should use the adns module for non-blocking DNS where available.
- Should probably not depend on python-socketcache, but should use it where available.
- Add a simple Timer class supporting
withsyntax (__enter__and__exit__) - Tests
Contributions welcome!