Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/sidecar/proxy/chat_completions.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ func (s *Server) chatCompletionsHandler(w http.ResponseWriter, r *http.Request)
ctx = context.WithValue(ctx, requestStartTimeKey, requestStart)
r = r.WithContext(ctx)

// Set span attributes with safe defaults for nil values
requestPath := ""
if r.URL != nil {
requestPath = r.URL.Path
}
span.SetAttributes(
attribute.String("llm_d.pd_proxy.connector", s.config.Connector),
attribute.String("llm_d.pd_proxy.request_path", r.URL.Path),
attribute.String("llm_d.pd_proxy.request_path", requestPath),
)

var prefillHostPorts []string
Expand Down
6 changes: 5 additions & 1 deletion pkg/sidecar/proxy/proxy_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ func (s *Server) startHTTP(ctx context.Context, cert *tls.Certificate) error {
// Wrap handler with OpenTelemetry middleware to extract trace context from incoming requests
handler := otelhttp.NewHandler(s.handler, "llm-d-pd-proxy",
otelhttp.WithSpanNameFormatter(func(_ string, r *http.Request) string {
return "llm_d.pd_proxy." + r.Method + " " + r.URL.Path
path := ""
if r.URL != nil {
path = r.URL.Path
}
return "llm_d.pd_proxy." + r.Method + " " + path
}),
)

Expand Down