Skip to content

Commit

Permalink
chore: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan committed Oct 22, 2022
1 parent 8d3d234 commit a8e142f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions rest/handler/tracinghandler.go
Expand Up @@ -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.
Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion rest/handler/tracinghandler_test.go
Expand Up @@ -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) {
Expand Down

0 comments on commit a8e142f

Please sign in to comment.