From 74c33d9ece28b2d19b4a88e58db020fed5d6c819 Mon Sep 17 00:00:00 2001 From: eric <1048315650@qq.com> Date: Sun, 21 Apr 2024 12:38:22 +0800 Subject: [PATCH] chore(middleware/metrics): if requests and seconds are nil, return directly --- middleware/metrics/metrics.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/middleware/metrics/metrics.go b/middleware/metrics/metrics.go index 7751648d32c..4459cdeefb1 100644 --- a/middleware/metrics/metrics.go +++ b/middleware/metrics/metrics.go @@ -100,6 +100,11 @@ func Server(opts ...Option) middleware.Middleware { } return func(handler middleware.Handler) middleware.Handler { return func(ctx context.Context, req interface{}) (interface{}, error) { + // if requests and seconds are nil, return directly + if op.requests == nil && op.seconds == nil { + return handler(ctx, req) + } + var ( code int reason string