From a8e142fe62fab46d527166386682cc7816b1c3d4 Mon Sep 17 00:00:00 2001 From: kevin Date: Sat, 22 Oct 2022 22:17:37 +0800 Subject: [PATCH] chore: refactor --- rest/handler/tracinghandler.go | 11 +++++------ rest/handler/tracinghandler_test.go | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/rest/handler/tracinghandler.go b/rest/handler/tracinghandler.go index 4e9e5f1ba927..9e258dfc3524 100644 --- a/rest/handler/tracinghandler.go +++ b/rest/handler/tracinghandler.go @@ -12,11 +12,11 @@ import ( oteltrace "go.opentelemetry.io/otel/trace" ) -var dontTracingSpanNames sync.Map +var notTracingSpans sync.Map -// DontTracingSpanName disable tracing for the specified spanName. -func DontTracingSpanName(spanName string) { - dontTracingSpanNames.Store(spanName, lang.Placeholder) +// DontTraceSpan disable tracing for the specified span name. +func DontTraceSpan(spanName string) { + notTracingSpans.Store(spanName, lang.Placeholder) } // TracingHandler return a middleware that process the opentelemetry. @@ -36,8 +36,7 @@ func TracingHandler(serviceName, path string) func(http.Handler) http.Handler { spanName = r.URL.Path } - _, ok := dontTracingSpanNames.Load(spanName) - if ok { + if _, ok := notTracingSpans.Load(spanName); ok { return } diff --git a/rest/handler/tracinghandler_test.go b/rest/handler/tracinghandler_test.go index bbc60911101c..c1d224d6fc00 100644 --- a/rest/handler/tracinghandler_test.go +++ b/rest/handler/tracinghandler_test.go @@ -60,7 +60,7 @@ func TestDontTracingSpanName(t *testing.T) { Sampler: 1.0, }) - DontTracingSpanName("bar") + DontTraceSpan("bar") for _, test := range []string{"", "bar", "foo"} { t.Run(test, func(t *testing.T) {