alexcesaro/statsd

Add int64 variants on metric functions

Taik opened this issue · 4 comments

Taik commented

Before I go ahead with a PR, what do you think about exposing "int64-variants" of the current metric functions?

I was thinking of something like:

func (c *Client) Count(bucket string, n int, rate float32) { ... }
func (c *Client) Count64(bucket string, n int64, rate float32) { ... }
func (c *Client) Gauge(bucket string, value int) { ... }
func (c *Client) Gauge64(bucket string, value int64) { ... }

... and so on for the rest of the supported calls.

Thanks but I don't think this is the right way to support more numeral types: if users request support for uint, float64, etc the API will soon be bloated.

I am currently in holidays and will think about supporting more types when I get back (early March).

By the way what is the reason you don't want to convert your int64 to int?

Taik commented

That's a good point. The reason why I suggested is because of int overflow (see: https://play.golang.org/p/DU-kIKuyQF), and I can't actually report negative numbers :)

I just released statsd.v2 which accepts interface{} instead of int with almost no performance loss.

Taik commented

Perfect--thanks, I'll give this a spin! It's a lot cleaner than what I was envisioning :)