I was exploring statsd's module code in beats while making some changes to the same and I noticed that the for metrics of type counter, we just support integers (of base 10 and 64 bitsize) and in case it is not the same, it errors out. But ideally it should be able to handle float values as well.
If we refer statsd'd official repository's docs: GitHub - statsd/statsd: Daemon for easy but powerful stats aggregation then we can see the following as the definition of values:
Each stat will have a value. How it is interpreted depends on modifiers. In general values should be integers.
So in general the values are integers but ideally the parsers should handle other scenarios as well. Looking at the code, changes look simple and I'd like to volunteer for the same. Also, several statsd client packages allow setting counter or gauge values with float64.
Example error that we get if we try to parse float values:
strconv.ParseInt: parsing "11.0": invalid syntax failed to process counter
Also, do see this: Statsd counter float values · Issue #556 · influxdata/telegraf · GitHub; telegraf also had a same issue when parsing metrics from consul. The fix was done as part of this PR: statsd: If parsing a value to int fails, try to float and cast to int by sparrc · Pull Request #561 · influxdata/telegraf · GitHub.
So, in case we are making this change, then what should be the approach:
- Parse float values and keep it as it is.
- Parse float values and cast it to int like telegraf is doing?