github / brubeck

A Statsd-compatible metrics aggregator
MIT License
1.19k stars 94 forks source link

Negative gauge values #43

Open Evertras opened 8 years ago

Evertras commented 8 years ago

Right now sending the following values...

val:-1|g val:-1|g val:-1|g

...in a flush cycle will output a final value of -3. But since this is a gauge, it's expected to be -1. This appears to be due to the following code:

https://github.com/github/brubeck/blob/master/src/samplers/statsd.c#L105

https://github.com/github/brubeck/blob/master/src/metric.c#L48

There seem to be some statsd aggregators that support negative gauges and some that do not. What is brubeck's stance, and what would be the best recommended way to get this functionality from brubeck? Maybe a runtime configuration switch to remove relative values from gauges altogether?

alindeman commented 8 years ago

Unfortunately this is actually the correct behavior according to statsd: https://github.com/etsy/statsd/blob/master/docs/metric_types.md#gauges

This implies you can't explicitly set a gauge to a negative number without first setting it to zero.