alexcesaro / statsd

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

Timing() time.Duration support #25

Open llecigne opened 7 years ago

llecigne commented 7 years ago

Sometimes Timing struct cannot be used because duration to record is known using a starting date coming from another context (DB or whatever).

When using Client.Timing method, caller has to manually redo the int64 casting/millisecond truncating by hand because time.Duration is not supported.

ex:

startDate := ... // some time.Time coming from another context
client.Timing(int64(time.Now().Sub(startDate)/time.Millisecond))

a simpler alternative would be

client.Timing(time.Now().Sub(startDate))