any-sync/metric/drpc.go
2023-01-05 15:34:09 +03:00

21 lines
420 B
Go

package metric
import (
"github.com/prometheus/client_golang/prometheus"
"storj.io/drpc"
"time"
)
type PrometheusDRPC struct {
drpc.Handler
SummaryVec *prometheus.SummaryVec
}
func (ph *PrometheusDRPC) HandleRPC(stream drpc.Stream, rpc string) (err error) {
st := time.Now()
defer func() {
ph.SummaryVec.WithLabelValues(rpc).Observe(time.Since(st).Seconds())
}()
return ph.Handler.HandleRPC(stream, rpc)
}