segmentio / stats

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

Add RPC stats. #53

Closed f2prateek closed 7 years ago

f2prateek commented 7 years ago

This adds an RPC invoker implementation that records RPC stats.

It records 2 stats:

  1. Counter for jsonrpc.call.
  2. Histogram for jsonrpc.duration.

Each of these contains the following tags:

  1. method - the RPC method.
  2. resource - the resource if the method is of the form "resource.function".
  3. function - the function if the method is of the form "resource.function".
  4. result - either "error", "success", "panic".
f2prateek commented 7 years ago

I don't need this ASAP, so we can take the time to fix any issues here (e.g. switching to the new API might be a good idea).

I wasn't sure for the best place for this. An argument could be made for this to be in rpc as well. Let me know if you strong opinions either way.

f2prateek commented 7 years ago

Lastly, I added the test handler to it's own package. I think most of the test handlers in the sub packages are the same, so it would be nice to have a single one they can reuse.

achille-roussel commented 7 years ago

On your question about whether it makes more sense to put it here or in the rpc package, I think it's fine to have it here, so we keep everything stats related in a single location.

f2prateek commented 7 years ago

At first glance, build failures seem unrelated to the change, I'll dig in later.

f2prateek commented 7 years ago

Closing this as per discussion on slack.