librato/statsd-librato-backend — pull request #36 by mheffner (2014-01-09 16:40:19+00:00)
Title: Fix native counters when using deleteIdleStats

When using native Librato counters (countersAsGauges:false) and periodically incrementing a statsd counter by one, you'll see the following on your graph:

(time: t_1, value: 10, delta: 1)
(time: t_4, value: 11, delta: 1)
...

However, if you enable deleteIdleStats and don't push an increment during a flush interval, the counter state is deleted in the backend and you'll see the following as the value is restarted at one for each increment:

(time: t_1, value: 1, delta: 0)
(time: t_4, value: 1, delta: 0)

This patch will push a zero when the counter is deleted (ie, wasn't updated in a flush interval), thereby giving the following:

(time: t_0, value 0, delta: 0)
(time: t_1, value 1, delta: 1)
(time: t_2, value 0, delta: 0)
(time: t_4, value 1, delta: 1)

Which should match the deltas when not deleting the counters in between increments.