mirror of
https://github.com/linka-cloud/grpc.git
synced 2024-11-22 02:46:25 +00:00
metrics: add server interceptor missing prometheus collector wrapped method
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
parent
b1988e0458
commit
d61f0e9d76
@ -2,6 +2,7 @@ package metrics
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
"go.linka.cloud/grpc/interceptors"
|
"go.linka.cloud/grpc/interceptors"
|
||||||
@ -13,13 +14,14 @@ type Registerer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Interceptors interface {
|
type Interceptors interface {
|
||||||
interceptors.Interceptors
|
ServerInterceptors
|
||||||
Registerer
|
ClientInterceptors
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServerInterceptors interface {
|
type ServerInterceptors interface {
|
||||||
interceptors.ServerInterceptors
|
|
||||||
Registerer
|
Registerer
|
||||||
|
interceptors.ServerInterceptors
|
||||||
|
prometheus.Collector
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClientInterceptors interface {
|
type ClientInterceptors interface {
|
||||||
@ -31,6 +33,18 @@ type metrics struct {
|
|||||||
c *grpc_prometheus.ClientMetrics
|
c *grpc_prometheus.ClientMetrics
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *metrics) Describe(descs chan<- *prometheus.Desc) {
|
||||||
|
if m.s != nil {
|
||||||
|
m.s.Describe(descs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *metrics) Collect(c chan<- prometheus.Metric) {
|
||||||
|
if m.s != nil {
|
||||||
|
m.s.Collect(c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (m *metrics) Register(svc service.Service) {
|
func (m *metrics) Register(svc service.Service) {
|
||||||
if m.s != nil {
|
if m.s != nil {
|
||||||
m.s.InitializeMetrics(svc)
|
m.s.InitializeMetrics(svc)
|
||||||
|
Loading…
Reference in New Issue
Block a user