fix typo of prometheus
This commit is contained in:
@@ -110,7 +110,7 @@ func (s *engine) bindRoute(fr featuredRoutes, router httpx.Router, metrics *stat
|
|||||||
handler.TimeoutHandler(time.Duration(s.conf.Timeout)*time.Millisecond),
|
handler.TimeoutHandler(time.Duration(s.conf.Timeout)*time.Millisecond),
|
||||||
handler.RecoverHandler,
|
handler.RecoverHandler,
|
||||||
handler.MetricHandler(metrics),
|
handler.MetricHandler(metrics),
|
||||||
handler.PrometheousHandler(route.Path),
|
handler.PromethousHandler(route.Path),
|
||||||
handler.MaxBytesHandler(s.conf.MaxBytes),
|
handler.MaxBytesHandler(s.conf.MaxBytes),
|
||||||
handler.GunzipHandler,
|
handler.GunzipHandler,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ var (
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
func PrometheousHandler(path string) func(http.Handler) http.Handler {
|
func PromethousHandler(path string) func(http.Handler) http.Handler {
|
||||||
return func(next http.Handler) http.Handler {
|
return func(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
startTime := timex.Now()
|
startTime := timex.Now()
|
||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestPromMetricHandler(t *testing.T) {
|
func TestPromMetricHandler(t *testing.T) {
|
||||||
promMetricHandler := PrometheousHandler("/user/login")
|
promMetricHandler := PromethousHandler("/user/login")
|
||||||
handler := promMetricHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
handler := promMetricHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
}))
|
}))
|
||||||
@@ -74,7 +74,7 @@ func buildDialOptions(opts ...ClientOption) []grpc.DialOption {
|
|||||||
clientinterceptors.TracingInterceptor,
|
clientinterceptors.TracingInterceptor,
|
||||||
clientinterceptors.DurationInterceptor,
|
clientinterceptors.DurationInterceptor,
|
||||||
clientinterceptors.BreakerInterceptor,
|
clientinterceptors.BreakerInterceptor,
|
||||||
clientinterceptors.PrometheousInterceptor,
|
clientinterceptors.PrometheusInterceptor,
|
||||||
clientinterceptors.TimeoutInterceptor(clientOptions.Timeout),
|
clientinterceptors.TimeoutInterceptor(clientOptions.Timeout),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ var (
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
func PrometheousInterceptor(ctx context.Context, method string, req, reply interface{},
|
func PrometheusInterceptor(ctx context.Context, method string, req, reply interface{},
|
||||||
cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||||
startTime := timex.Now()
|
startTime := timex.Now()
|
||||||
err := invoker(ctx, method, req, reply, cc, opts...)
|
err := invoker(ctx, method, req, reply, cc, opts...)
|
||||||
@@ -26,7 +26,7 @@ func TestPromMetricInterceptor(t *testing.T) {
|
|||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
cc := new(grpc.ClientConn)
|
cc := new(grpc.ClientConn)
|
||||||
err := PrometheousInterceptor(context.Background(), "/foo", nil, nil, cc,
|
err := PrometheusInterceptor(context.Background(), "/foo", nil, nil, cc,
|
||||||
func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn,
|
func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn,
|
||||||
opts ...grpc.CallOption) error {
|
opts ...grpc.CallOption) error {
|
||||||
return test.err
|
return test.err
|
||||||
@@ -55,7 +55,7 @@ func (s *rpcServer) Start(register RegisterFn) error {
|
|||||||
serverinterceptors.UnaryTracingInterceptor(s.name),
|
serverinterceptors.UnaryTracingInterceptor(s.name),
|
||||||
serverinterceptors.UnaryCrashInterceptor(),
|
serverinterceptors.UnaryCrashInterceptor(),
|
||||||
serverinterceptors.UnaryStatInterceptor(s.metrics),
|
serverinterceptors.UnaryStatInterceptor(s.metrics),
|
||||||
serverinterceptors.UnaryPrometheousInterceptor(),
|
serverinterceptors.UnaryPrometheusInterceptor(),
|
||||||
}
|
}
|
||||||
unaryInterceptors = append(unaryInterceptors, s.unaryInterceptors...)
|
unaryInterceptors = append(unaryInterceptors, s.unaryInterceptors...)
|
||||||
streamInterceptors := []grpc.StreamServerInterceptor{
|
streamInterceptors := []grpc.StreamServerInterceptor{
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ var (
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
func UnaryPrometheousInterceptor() grpc.UnaryServerInterceptor {
|
func UnaryPrometheusInterceptor() grpc.UnaryServerInterceptor {
|
||||||
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (
|
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (
|
||||||
interface{}, error) {
|
interface{}, error) {
|
||||||
startTime := timex.Now()
|
startTime := timex.Now()
|
||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestUnaryPromMetricInterceptor(t *testing.T) {
|
func TestUnaryPromMetricInterceptor(t *testing.T) {
|
||||||
interceptor := UnaryPrometheousInterceptor()
|
interceptor := UnaryPrometheusInterceptor()
|
||||||
_, err := interceptor(context.Background(), nil, &grpc.UnaryServerInfo{
|
_, err := interceptor(context.Background(), nil, &grpc.UnaryServerInfo{
|
||||||
FullMethod: "/",
|
FullMethod: "/",
|
||||||
}, func(ctx context.Context, req interface{}) (interface{}, error) {
|
}, func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
Reference in New Issue
Block a user