segmentio / stats

Go package for abstracting stats collection
https://godoc.org/github.com/segmentio/stats
MIT License
208 stars 32 forks source link

add MetricType.String #29

Closed achille-roussel closed 7 years ago

achille-roussel commented 7 years ago

Useful for debugging purposes.

f2prateek commented 7 years ago

Should just go generate this.

achille-roussel commented 7 years ago

I've never used go generate but I'm happy to rework it to auto-generate the values. Do you know of any good reads on this topic?

f2prateek commented 7 years ago

Not sure how I originally discovered it, but these docs are pretty good https://godoc.org/golang.org/x/tools/cmd/stringer.

It'll generate something like https://github.com/segmentio/event-rules-counters/blob/master/precision/p_string.go.

You can "automate" it with go generate like this https://github.com/segmentio/event-rules-counters/blob/master/precision/precision.go#L10.

behaviour wise, it'll be slightly different from your current implementation. e.g. CounterType will print CounterType not counter as currently implemented.