alexcesaro/statsd

conn.appendNumber() should have a default case

Opened this issue · 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 :)