disable prometheus if not configured (#663)
This commit is contained in:
@@ -5,10 +5,25 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/tal-tech/go-zero/core/prometheus"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
func TestUnaryPromMetricInterceptor(t *testing.T) {
|
||||
func TestUnaryPromMetricInterceptor_Disabled(t *testing.T) {
|
||||
interceptor := UnaryPrometheusInterceptor()
|
||||
_, err := interceptor(context.Background(), nil, &grpc.UnaryServerInfo{
|
||||
FullMethod: "/",
|
||||
}, func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return nil, nil
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestUnaryPromMetricInterceptor_Enabled(t *testing.T) {
|
||||
prometheus.StartAgent(prometheus.Config{
|
||||
Host: "localhost",
|
||||
Path: "/",
|
||||
})
|
||||
interceptor := UnaryPrometheusInterceptor()
|
||||
_, err := interceptor(context.Background(), nil, &grpc.UnaryServerInfo{
|
||||
FullMethod: "/",
|
||||
|
||||
Reference in New Issue
Block a user