From de1bf47e00f56d4334426e62996a4d53d0bf79b3 Mon Sep 17 00:00:00 2001 From: Harsh Rajput Date: Fri, 13 Oct 2023 12:50:04 +0530 Subject: [PATCH] fix read-write race check in metrics middleware --- metrics/runner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metrics/runner.go b/metrics/runner.go index b1e7113..c95d881 100644 --- a/metrics/runner.go +++ b/metrics/runner.go @@ -43,6 +43,7 @@ func NewMiddleware(id string, rec Recorder) goresilience.Middleware { rec = rec.WithID(id) return func(next goresilience.Runner) goresilience.Runner { + next = goresilience.SanitizeRunner(next) return goresilience.RunnerFunc(func(ctx context.Context, f goresilience.Func) (err error) { defer func(start time.Time) { rec.ObserveCommandExecution(start, err == nil) @@ -53,7 +54,6 @@ func NewMiddleware(id string, rec Recorder) goresilience.Middleware { // by the context. Measure if this has a big impact. ctx = SetRecorderOnContext(ctx, rec) - next = goresilience.SanitizeRunner(next) err = next.Run(ctx, f) return err