Archived
修正协议处理并解耦可选遥测
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package telemetry
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
|
||||
"go.opentelemetry.io/otel/propagation"
|
||||
)
|
||||
|
||||
func WrapHTTP(handler http.Handler, providers *Providers, propagators propagation.TextMapPropagator) http.Handler {
|
||||
if providers == nil {
|
||||
return handler
|
||||
}
|
||||
|
||||
options := []otelhttp.Option{
|
||||
otelhttp.WithTracerProvider(providers.Tracer),
|
||||
otelhttp.WithMeterProvider(providers.Meter),
|
||||
}
|
||||
if propagators != nil {
|
||||
options = append(options, otelhttp.WithPropagators(propagators))
|
||||
}
|
||||
return otelhttp.NewHandler(handler, "workload-sts.http", options...)
|
||||
}
|
||||
Reference in New Issue
Block a user