From e50e3ed93a365104c98c67f1b081e86bb83587c8 Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Mon, 1 Sep 2025 20:03:17 +0300 Subject: [PATCH] create otel transport in Provision Signed-off-by: Mohammed Al Sahaf --- modules/caddyhttp/reverseproxy/reverseproxy.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/caddyhttp/reverseproxy/reverseproxy.go b/modules/caddyhttp/reverseproxy/reverseproxy.go index a2a8d6b86..4836cf3b4 100644 --- a/modules/caddyhttp/reverseproxy/reverseproxy.go +++ b/modules/caddyhttp/reverseproxy/reverseproxy.go @@ -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 { h.RequestBuffers = 4096 } + h.Transport = otelhttp.NewTransport(h.Transport) } if h.LoadBalancing != nil && h.LoadBalancing.SelectionPolicyRaw != nil { 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 start := time.Now() - otelTransport := otelhttp.NewTransport(h.Transport) - res, err := otelTransport.RoundTrip(req) + res, err := h.Transport.RoundTrip(req) duration := time.Since(start) // record that the round trip is done for the 1xx response handler