修正协议处理并解耦可选遥测

This commit is contained in:
2026-09-11 16:10:27 +00:00
parent ab5dbebca7
commit 0532fc25bf
9 changed files with 128 additions and 83 deletions
+23
View File
@@ -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...)
}