Skip to content

Commit 9099259

Browse files
authored
Merge pull request #1 from Gregory-Pereira/tracing
protect against segfault on tests
2 parents e7b7d29 + d747153 commit 9099259

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pkg/sidecar/proxy/chat_completions.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,14 @@ func (s *Server) chatCompletionsHandler(w http.ResponseWriter, r *http.Request)
5454
ctx = context.WithValue(ctx, requestStartTimeKey, requestStart)
5555
r = r.WithContext(ctx)
5656

57+
// Set span attributes with safe defaults for nil values
58+
requestPath := ""
59+
if r.URL != nil {
60+
requestPath = r.URL.Path
61+
}
5762
span.SetAttributes(
5863
attribute.String("llm_d.pd_proxy.connector", s.config.Connector),
59-
attribute.String("llm_d.pd_proxy.request_path", r.URL.Path),
64+
attribute.String("llm_d.pd_proxy.request_path", requestPath),
6065
)
6166

6267
var prefillHostPorts []string

pkg/sidecar/proxy/proxy_helpers.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ func (s *Server) startHTTP(ctx context.Context, cert *tls.Certificate) error {
3232
// Wrap handler with OpenTelemetry middleware to extract trace context from incoming requests
3333
handler := otelhttp.NewHandler(s.handler, "llm-d-pd-proxy",
3434
otelhttp.WithSpanNameFormatter(func(_ string, r *http.Request) string {
35-
return "llm_d.pd_proxy." + r.Method + " " + r.URL.Path
35+
path := ""
36+
if r.URL != nil {
37+
path = r.URL.Path
38+
}
39+
return "llm_d.pd_proxy." + r.Method + " " + path
3640
}),
3741
)
3842

0 commit comments

Comments
 (0)