File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed
main/java/datadog/trace/api
test/groovy/datadog/trace/api Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -4741,8 +4741,18 @@ public String getFinalProfilingUrl() {
47414741 // when agentless profiling is turned on we send directly to our intake
47424742 return "https://intake.profile." + site + "/api/v2/profile" ;
47434743 } else {
4744- // when profilingUrl and agentless are not set we send to the dd trace agent running locally
4745- return getAgentUrl () + "/profiling/v1/input" ;
4744+ // When profilingUrl and agentless are not set we send to the dd trace agent running locally
4745+ // However, there are two gotchas:
4746+ // - the agentHost, agentPort split will trip on IPv6 addresses because of the colon -> we
4747+ // need to use the agentUrl
4748+ // - but the agentUrl can be unix socket and OKHttp doesn't support that so we fall back to
4749+ // http
4750+ //
4751+ // There is some magic behind the scenes where the http url will be converted to UDS if the
4752+ // target is a unix socket only
4753+ String baseUrl =
4754+ agentUrl .startsWith ("unix:" ) ? "http://" + agentHost + ":" + agentPort : agentUrl ;
4755+ return baseUrl + "/profiling/v1/input" ;
47464756 }
47474757 }
47484758
Original file line number Diff line number Diff line change @@ -1665,6 +1665,19 @@ class ConfigTest extends DDSpecification {
16651665 config. getFinalProfilingUrl() == configuredUrl + " /profiling/v1/input"
16661666 }
16671667
1668+ def " uds profiling url" () {
1669+ setup :
1670+ def configuredUrl = " unix:///path/to/socket"
1671+ def props = new Properties ()
1672+ props. setProperty(TRACE_AGENT_URL , configuredUrl)
1673+
1674+ when :
1675+ Config config = Config . get(props)
1676+
1677+ then :
1678+ config. getFinalProfilingUrl() == " http://" + config. getAgentHost() + " :" + config. getAgentPort() + " /profiling/v1/input"
1679+ }
1680+
16681681 def " fallback to DD_TAGS" () {
16691682 setup :
16701683 environmentVariables. set(DD_TAGS_ENV , " a:1,b:2,c:3" )
You can’t perform that action at this time.
0 commit comments