mirror of
https://github.com/caddyserver/caddy.git
synced 2025-04-22 04:18:47 +08:00
more tracing
This commit is contained in:
parent
9c4d0943a4
commit
9467bf8d12
caddyconfig
cmd
modules/caddyhttp/reverseproxy
@ -98,8 +98,13 @@ func (hl HTTPLoader) LoadConfig(ctx caddy.Context) ([]byte, error) {
|
||||
method = http.MethodGet
|
||||
}
|
||||
|
||||
// tr := otel.Tracer("caddyconfig")
|
||||
|
||||
// ctx, span := tr.Start(ctx, "httploader")
|
||||
// defer span.End()
|
||||
|
||||
url := repl.ReplaceAll(hl.URL, "")
|
||||
req, err := http.NewRequest(method, url, nil)
|
||||
req, err := http.NewRequestWithContext(ctx, method, url, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -670,7 +670,7 @@ func AdminAPIRequest(adminAddr, method, uri string, headers http.Header, body io
|
||||
}
|
||||
|
||||
// form the request
|
||||
req, err := http.NewRequest(method, origin+uri, body)
|
||||
req, err := http.NewRequestWithContext(context.TODO(), method, origin+uri, body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("making request: %v", err)
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
|
||||
@ -429,6 +430,12 @@ func (h *Handler) doActiveHealthCheck(dialInfo DialInfo, hostAddr string, networ
|
||||
ctx = context.WithValue(ctx, caddyhttp.VarsCtxKey, map[string]any{
|
||||
dialInfoVarKey: dialInfo,
|
||||
})
|
||||
|
||||
tr := otel.Tracer("reverseproxy")
|
||||
|
||||
ctx, span := tr.Start(ctx, "healthcheck")
|
||||
defer span.End()
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, h.HealthChecks.Active.Method, u.String(), requestBody)
|
||||
if err != nil {
|
||||
return fmt.Errorf("making request: %v", err)
|
||||
|
@ -34,6 +34,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
"golang.org/x/net/http/httpguts"
|
||||
@ -863,6 +864,7 @@ func (h *Handler) reverseProxy(rw http.ResponseWriter, req *http.Request, origRe
|
||||
},
|
||||
}
|
||||
req = req.WithContext(httptrace.WithClientTrace(req.Context(), trace))
|
||||
req = req.WithContext(httptrace.WithClientTrace(req.Context(), otelhttptrace.NewClientTrace(req.Context())))
|
||||
|
||||
// do the round-trip
|
||||
start := time.Now()
|
||||
|
Loading…
x
Reference in New Issue
Block a user