graphyte
graphyte copied to clipboard
Add support for sending data in pickle format
The pickle protocol is somewhat more efficient, especially when sending a bunch of metrics at once. Would be nice to add an option to send data using the pickle format, as per http://graphite.readthedocs.io/en/latest/feeding-carbon.html:
list_of_metric_tuples = [(path, (timestamp, value)), ...]
payload = pickle.dumps(list_of_metric_tuples, protocol=2)
header = struct.pack("!L", len(payload))
message = header + payload
Perhaps add a protocol='pickle' option to Sender.__init__ (defaults to plaintext). It'd be nice if the port argument defaulted to None, and then if None we'd select the default port based on protocol (plaintext=2003, pickle=2004).
If it just sent one at a time in foreground (interval=None) mode, I think that's fine, and the benefits would only kick in if you were in background (interval) mode. But I think that's fine.
I like this idea. It would be quite useful.
I'll put up a PR