From 863b9b293b2489d8a6e2a5c5ffc01183d9117fcb Mon Sep 17 00:00:00 2001 From: Nick Ripley Date: Thu, 2 Feb 2023 13:37:34 -0800 Subject: [PATCH] ddtrace/tracer: replace Windows path characters in fake UDS host (#1713) We still need to give a full URL to the HTTP client, with the "http" scheme, but we want the URL to somewhat resemble the UDS path. Windows paths contain colons and back-slashes. Colons in particular cause trouble because they're usually followed by a port. Replace those characters with something else. --- ddtrace/tracer/option.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddtrace/tracer/option.go b/ddtrace/tracer/option.go index c84911bb74..63501297a8 100644 --- a/ddtrace/tracer/option.go +++ b/ddtrace/tracer/option.go @@ -230,7 +230,7 @@ func newConfig(opts ...StartOption) *config { c.httpClient = udsClient(c.agentURL.Path) c.agentURL = &url.URL{ Scheme: "http", - Host: fmt.Sprintf("UDS_%s", strings.ReplaceAll(c.agentURL.Path, "/", "_")), + Host: fmt.Sprintf("UDS_%s", strings.NewReplacer(":", "_", "/", "_", `\`, "_").Replace(c.agentURL.Path)), } } else if c.httpClient == nil { c.httpClient = defaultClient