mirror of
https://github.com/linka-cloud/grpc.git
synced 2024-12-22 08:50:46 +00:00
metrics interceptors: fix default server registration
metrics interceptors: add missing client histogram methods Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
parent
dcd2f18f65
commit
01b37a0d91
@ -110,7 +110,7 @@ func run(opts ...service.Option) {
|
||||
ready := make(chan struct{})
|
||||
var svc service.Service
|
||||
var err error
|
||||
metrics := metrics2.NewInterceptors()
|
||||
metrics := metrics2.DefaultInterceptors()
|
||||
validation := validation2.NewInterceptors(true)
|
||||
defaulter := defaulter.NewInterceptors()
|
||||
address := "0.0.0.0:9991"
|
||||
@ -156,6 +156,7 @@ func run(opts ...service.Option) {
|
||||
panic(err)
|
||||
}
|
||||
RegisterGreeterServer(svc, &GreeterHandler{})
|
||||
metrics.EnableHandlingTimeHistogram()
|
||||
metrics.Register(svc)
|
||||
go func() {
|
||||
if err := svc.Start(); err != nil {
|
||||
|
@ -23,6 +23,10 @@ type ServerInterceptors interface {
|
||||
interceptors.ServerInterceptors
|
||||
prometheus.Collector
|
||||
EnableHandlingTimeHistogram(opts ...grpc_prometheus.HistogramOption)
|
||||
|
||||
EnableClientHandlingTimeHistogram(opts ...grpc_prometheus.HistogramOption)
|
||||
EnableClientStreamReceiveTimeHistogram(opts ...grpc_prometheus.HistogramOption)
|
||||
EnableClientStreamSendTimeHistogram(opts ...grpc_prometheus.HistogramOption)
|
||||
}
|
||||
|
||||
type ClientInterceptors interface {
|
||||
@ -36,7 +40,41 @@ type metrics struct {
|
||||
|
||||
func (m *metrics) EnableHandlingTimeHistogram(opts ...grpc_prometheus.HistogramOption) {
|
||||
if m.s != nil {
|
||||
m.s.EnableHandlingTimeHistogram(opts...)
|
||||
if m.s == grpc_prometheus.DefaultServerMetrics {
|
||||
grpc_prometheus.EnableHandlingTimeHistogram(opts...)
|
||||
} else {
|
||||
m.s.EnableHandlingTimeHistogram(opts...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (m *metrics) EnableClientHandlingTimeHistogram(opts ...grpc_prometheus.HistogramOption) {
|
||||
if m.c != nil {
|
||||
if m.c == grpc_prometheus.DefaultClientMetrics {
|
||||
grpc_prometheus.EnableClientHandlingTimeHistogram(opts...)
|
||||
} else {
|
||||
m.c.EnableClientHandlingTimeHistogram(opts...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (m *metrics) EnableClientStreamReceiveTimeHistogram(opts ...grpc_prometheus.HistogramOption) {
|
||||
if m.c != nil {
|
||||
if m.c == grpc_prometheus.DefaultClientMetrics {
|
||||
grpc_prometheus.EnableClientStreamReceiveTimeHistogram(opts...)
|
||||
} else {
|
||||
m.c.EnableClientStreamReceiveTimeHistogram(opts...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (m *metrics) EnableClientStreamSendTimeHistogram(opts ...grpc_prometheus.HistogramOption) {
|
||||
if m.c != nil {
|
||||
if m.c == grpc_prometheus.DefaultClientMetrics {
|
||||
grpc_prometheus.EnableClientStreamSendTimeHistogram(opts...)
|
||||
} else {
|
||||
m.c.EnableClientStreamSendTimeHistogram(opts...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user