gotsrpc/instrumentation.go
Stefan Martinov adae02a23f
feat: update go-modules and add objectives to summary vectors (#21)
- add instrumentation handler to allow handling stats
2019-10-25 12:32:32 +02:00

15 lines
340 B
Go

package gotsrpc
import "net/http"
func InstrumentedService(middleware http.HandlerFunc, handleStats GoRPCCallStatsHandlerFun) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
*r = *RequestWithStatsContext(r)
middleware(w, r)
stats := GetStatsForRequest(r)
if stats != nil {
handleStats(stats)
}
}
}