31 lines
985 B
Go
31 lines
985 B
Go
package grpc
|
|
|
|
import (
|
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
|
grpcprom "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus"
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
var clientMetrics *grpcprom.ClientMetrics = grpcprom.NewClientMetrics(
|
|
grpcprom.WithClientHandlingTimeHistogram(
|
|
grpcprom.WithHistogramBuckets(prometheus.DefBuckets),
|
|
),
|
|
grpcprom.WithClientStreamRecvHistogram(
|
|
grpcprom.WithHistogramBuckets(prometheus.DefBuckets),
|
|
),
|
|
)
|
|
|
|
func init() {
|
|
metrics.Register(clientMetrics)
|
|
}
|
|
|
|
// NewUnaryClientInterceptor returns client interceptor to collect metrics from unary RPCs.
|
|
func NewUnaryClientInterceptor() grpc.UnaryClientInterceptor {
|
|
return clientMetrics.UnaryClientInterceptor()
|
|
}
|
|
|
|
// NewStreamClientInterceptor returns client interceptor to collect metrics from stream RPCs.
|
|
func NewStreamClientInterceptor() grpc.StreamClientInterceptor {
|
|
return clientMetrics.StreamClientInterceptor()
|
|
}
|