Subject: | Multi-metric gauge feature |
Date: | Sat, 29 Mar 2014 07:49:52 +0200 |
To: | bug-Net-Statsd [...] rt.cpan.org |
From: | Ville Mattila <vm [...] iki.fi> |
Hi,
Net::Statsd v0.08 works great but it's currently missing support for the
Multi-Metric Packets feature of statsd, described at
https://github.com/etsy/statsd/blob/master/docs/metric_types.md#multi-metric-packets
A simple(?) patch which makes Net::Statsd::gauge() accept multiple
metrics and modifies send() and _sample_data() accordingly to pack all
of metrics into single UDP packet is attached. AFAIK the module API
would remain backwards compatible. (The code works for me, but I've
never used the sampling features or anything but gauge() so I'm not at
all sure if the changes are correct/sane.)
Rationale: The possibility to pack multiple metrics into single UDP
packet is essential for me, as I'm collecting negative temperature
readings from remote locations (in Finland the outdoor temperature ⁰C
during winters typically is negative) which have very unreliable network
connections; statsd interprets gauge values with '+' or '-' sign as
increment/decrement and therefore to set a gauge to a negative value it
must be set to zero first. Now it is not a problem if I lose some
readings, but if the zero and the actual negative value are sent in
separate UDP packets my temperature data will become badly skewed if
either one of the UDP packets is lost or reordered in the network transit.
NB: The suggested patch is rather ugly, especially in how the $value's
passed to send() and _sample_data() can be either scalars (as in 0.08)
or array refs. Cleaner implementation wrt the module internals might be
good to have.
Thanks,
--
Ville Mattila
Message body not shown because it is not plain text.
Message body is not shown because sender requested not to inline it.
Message body not shown because it is not plain text.