alexcesaro / statsd

An efficient Statsd Go client.
MIT License
301 stars 79 forks source link

conn.appendNumber() should have a default case #28

Open tabacco opened 7 years ago

tabacco commented 7 years ago

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 :)