Skip to content

Commit 10fe43b

Browse files
committed
added OTEL client transport to healthchecks
1 parent 9467bf8 commit 10fe43b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

modules/caddyhttp/reverseproxy/healthchecks.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"io"
2121
"net"
2222
"net/http"
23+
"net/http/httptrace"
2324
"net/url"
2425
"regexp"
2526
"runtime/debug"
@@ -28,6 +29,9 @@ import (
2829
"strings"
2930
"time"
3031

32+
"go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace"
33+
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
34+
3135
"go.opentelemetry.io/otel"
3236
"go.uber.org/zap"
3337
"go.uber.org/zap/zapcore"
@@ -177,8 +181,13 @@ func (a *ActiveHealthChecks) Provision(ctx caddy.Context, h *Handler) error {
177181
}
178182

179183
a.httpClient = &http.Client{
180-
Timeout: timeout,
181-
Transport: h.Transport,
184+
Timeout: timeout,
185+
Transport: otelhttp.NewTransport(
186+
h.Transport,
187+
otelhttp.WithClientTrace(func(ctx context.Context) *httptrace.ClientTrace {
188+
return otelhttptrace.NewClientTrace(ctx)
189+
}),
190+
),
182191
CheckRedirect: func(req *http.Request, via []*http.Request) error {
183192
if !a.FollowRedirects {
184193
return http.ErrUseLastResponse

0 commit comments

Comments
 (0)