gotsrpc/instrumentation.go
Kevin Franklin Kim 7faf7e4c98 feat: add monitor
2022-05-04 11:16:04 +02:00

14 lines
333 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)
if stats, ok := GetStatsForRequest(r); ok {
handleStats(stats)
}
}
}