Skip to content

Commit 9467bf8

Browse files
committed
more tracing
1 parent 9c4d094 commit 9467bf8

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

caddyconfig/httploader.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,13 @@ func (hl HTTPLoader) LoadConfig(ctx caddy.Context) ([]byte, error) {
9898
method = http.MethodGet
9999
}
100100

101+
// tr := otel.Tracer("caddyconfig")
102+
103+
// ctx, span := tr.Start(ctx, "httploader")
104+
// defer span.End()
105+
101106
url := repl.ReplaceAll(hl.URL, "")
102-
req, err := http.NewRequest(method, url, nil)
107+
req, err := http.NewRequestWithContext(ctx, method, url, nil)
103108
if err != nil {
104109
return nil, err
105110
}

cmd/commandfuncs.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ func AdminAPIRequest(adminAddr, method, uri string, headers http.Header, body io
670670
}
671671

672672
// form the request
673-
req, err := http.NewRequest(method, origin+uri, body)
673+
req, err := http.NewRequestWithContext(context.TODO(), method, origin+uri, body)
674674
if err != nil {
675675
return nil, fmt.Errorf("making request: %v", err)
676676
}

modules/caddyhttp/reverseproxy/healthchecks.go

+7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"strings"
2929
"time"
3030

31+
"go.opentelemetry.io/otel"
3132
"go.uber.org/zap"
3233
"go.uber.org/zap/zapcore"
3334

@@ -429,6 +430,12 @@ func (h *Handler) doActiveHealthCheck(dialInfo DialInfo, hostAddr string, networ
429430
ctx = context.WithValue(ctx, caddyhttp.VarsCtxKey, map[string]any{
430431
dialInfoVarKey: dialInfo,
431432
})
433+
434+
tr := otel.Tracer("reverseproxy")
435+
436+
ctx, span := tr.Start(ctx, "healthcheck")
437+
defer span.End()
438+
432439
req, err := http.NewRequestWithContext(ctx, h.HealthChecks.Active.Method, u.String(), requestBody)
433440
if err != nil {
434441
return fmt.Errorf("making request: %v", err)

modules/caddyhttp/reverseproxy/reverseproxy.go

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"sync"
3535
"time"
3636

37+
"go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace"
3738
"go.uber.org/zap"
3839
"go.uber.org/zap/zapcore"
3940
"golang.org/x/net/http/httpguts"
@@ -863,6 +864,7 @@ func (h *Handler) reverseProxy(rw http.ResponseWriter, req *http.Request, origRe
863864
},
864865
}
865866
req = req.WithContext(httptrace.WithClientTrace(req.Context(), trace))
867+
req = req.WithContext(httptrace.WithClientTrace(req.Context(), otelhttptrace.NewClientTrace(req.Context())))
866868

867869
// do the round-trip
868870
start := time.Now()

0 commit comments

Comments
 (0)