|
|
|
@ -31,7 +31,7 @@ func TracingHandler(serviceName, path string, opts ...TracingOption) func(http.H
|
|
|
|
|
|
|
|
|
|
ignorePaths := collection.NewSet()
|
|
|
|
|
ignorePaths.AddStr(tracingOpts.traceIgnorePaths...)
|
|
|
|
|
|
|
|
|
|
traceHandler := func(checkIgnore bool) func(http.Handler) http.Handler {
|
|
|
|
|
return func(next http.Handler) http.Handler {
|
|
|
|
|
propagator := otel.GetTextMapPropagator()
|
|
|
|
|
tracer := otel.GetTracerProvider().Tracer(trace.TraceName)
|
|
|
|
@ -42,7 +42,7 @@ func TracingHandler(serviceName, path string, opts ...TracingOption) func(http.H
|
|
|
|
|
spanName = r.URL.Path
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ignorePaths.Contains(spanName) {
|
|
|
|
|
if checkIgnore && ignorePaths.Contains(spanName) {
|
|
|
|
|
next.ServeHTTP(w, r)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
@ -67,11 +67,14 @@ func TracingHandler(serviceName, path string, opts ...TracingOption) func(http.H
|
|
|
|
|
span.SetStatus(semconv.SpanStatusFromHTTPStatusCodeAndSpanKind(trw.Code, oteltrace.SpanKindServer))
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
checkIgnore := ignorePaths.Count() > 0
|
|
|
|
|
return traceHandler(checkIgnore)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// WithTraceIgnorePaths specifies the traceIgnorePaths option for TracingHandler.
|
|
|
|
|
func WithTraceIgnorePaths(traceIgnorePaths []string) TracingOption {
|
|
|
|
|
return func(options *tracingOptions) {
|
|
|
|
|
options.traceIgnorePaths = traceIgnorePaths
|
|
|
|
|
options.traceIgnorePaths = append(options.traceIgnorePaths, traceIgnorePaths...)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|