1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-11 10:18:08 +09:00
any-sync/metric/drpc.go
2023-04-21 17:00:35 +02:00

20 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)
}