statsd icon indicating copy to clipboard operation
statsd copied to clipboard

conn.appendNumber() should have a default case

Open tabacco opened this issue 8 years ago • 0 comments

https://github.com/alexcesaro/statsd/blob/master/conn.go#L136-L163

appendNumber accepts an interface{} assuming it'll get a number. But if it gets an unexpected type it appends nothing to the buffer, possibly generating an invalid metric like "somekey:|c". This can happen if, for example, you have a custom type that's aliased from uint64 that you try to pass in as a value to Count().

The simplest solution is probably to have the default case in that switch append '0', but that's also sort of annoyingly hard to debug. I don't have an amazing idea for an alternative here, but wanted to register the issue :)

tabacco avatar Jul 24 '17 19:07 tabacco