create otel transport in Provision

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
This commit is contained in:
Mohammed Al Sahaf 2025-09-01 20:03:17 +03:00
parent 9dfc038d38
commit e50e3ed93a
No known key found for this signature in database

View File

@ -257,6 +257,7 @@ func (h *Handler) Provision(ctx caddy.Context) error {
if module, ok := h.Transport.(caddy.Module); ok && module.CaddyModule().ID.Name() == "fastcgi" && h.RequestBuffers == 0 { if module, ok := h.Transport.(caddy.Module); ok && module.CaddyModule().ID.Name() == "fastcgi" && h.RequestBuffers == 0 {
h.RequestBuffers = 4096 h.RequestBuffers = 4096
} }
h.Transport = otelhttp.NewTransport(h.Transport)
} }
if h.LoadBalancing != nil && h.LoadBalancing.SelectionPolicyRaw != nil { if h.LoadBalancing != nil && h.LoadBalancing.SelectionPolicyRaw != nil {
mod, err := ctx.LoadModule(h.LoadBalancing, "SelectionPolicyRaw") mod, err := ctx.LoadModule(h.LoadBalancing, "SelectionPolicyRaw")
@ -867,8 +868,7 @@ func (h *Handler) reverseProxy(rw http.ResponseWriter, req *http.Request, origRe
// do the round-trip // do the round-trip
start := time.Now() start := time.Now()
otelTransport := otelhttp.NewTransport(h.Transport) res, err := h.Transport.RoundTrip(req)
res, err := otelTransport.RoundTrip(req)
duration := time.Since(start) duration := time.Since(start)
// record that the round trip is done for the 1xx response handler // record that the round trip is done for the 1xx response handler