graphyte icon indicating copy to clipboard operation
graphyte copied to clipboard

Add support for sending data in pickle format

Open benhoyt opened this issue 8 years ago • 2 comments

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.

benhoyt avatar Nov 23 '16 19:11 benhoyt

I like this idea. It would be quite useful.

benmoran56 avatar Apr 04 '17 09:04 benmoran56

I'll put up a PR

naphthalene avatar Aug 20 '18 02:08 naphthalene