go-tigertonic
go-tigertonic copied to clipboard
Handle unexpected status codes
Currently if you respond with a status code that doesn't explicitly have a counter set, you'll get a panic.
Hmm I'm not sure this is really what we want happening - the next person that comes along and has the same issue you had with 422
is just going to get a silent failure and no metrics. I'm inclined to think the panic is actually the right outcome here - lets you know the counter implementation doesn't know the code you're trying to return, and the fix seems straight-forward enough.
Very true. After realising that these are counters rather than meters we implemented our own version where we create a meter on demand for each status type. This reduces the amount of meters any one consumer will have, as I'd imagine not everyone is using all of the status codes, but also added a little bit more complexity with a mutex to prevent concurrency clobbering when initializing a meter.