2023-04-09 06:54:54 +00:00
|
|
|
package tracing
|
2023-04-09 06:30:15 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
|
|
|
|
)
|
|
|
|
|
|
|
|
// TracingHandler
|
|
|
|
func TracingHandler(operation string) func(next http.Handler) http.Handler {
|
|
|
|
return func(next http.Handler) http.Handler {
|
|
|
|
fn := func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
next.ServeHTTP(w, r)
|
|
|
|
}
|
|
|
|
return otelhttp.NewHandler(http.HandlerFunc(fn), operation)
|
|
|
|
}
|
|
|
|
}
|