mirror of
https://github.com/caddyserver/caddy.git
synced 2025-04-19 10:49:17 +08:00
added OTEL client transport to healthchecks
This commit is contained in:
parent
9467bf8d12
commit
10fe43b107
@ -20,6 +20,7 @@ import (
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httptrace"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"runtime/debug"
|
||||
@ -28,6 +29,9 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace"
|
||||
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
@ -177,8 +181,13 @@ func (a *ActiveHealthChecks) Provision(ctx caddy.Context, h *Handler) error {
|
||||
}
|
||||
|
||||
a.httpClient = &http.Client{
|
||||
Timeout: timeout,
|
||||
Transport: h.Transport,
|
||||
Timeout: timeout,
|
||||
Transport: otelhttp.NewTransport(
|
||||
h.Transport,
|
||||
otelhttp.WithClientTrace(func(ctx context.Context) *httptrace.ClientTrace {
|
||||
return otelhttptrace.NewClientTrace(ctx)
|
||||
}),
|
||||
),
|
||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||
if !a.FollowRedirects {
|
||||
return http.ErrUseLastResponse
|
||||
|
Loading…
x
Reference in New Issue
Block a user