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
14 changes: 12 additions & 2 deletions internal-api/src/main/java/datadog/trace/api/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -4741,8 +4741,18 @@ public String getFinalProfilingUrl() {
// when agentless profiling is turned on we send directly to our intake
return "https://intake.profile." + site + "/api/v2/profile";
} else {
// when profilingUrl and agentless are not set we send to the dd trace agent running locally
return getAgentUrl() + "/profiling/v1/input";
// When profilingUrl and agentless are not set we send to the dd trace agent running locally
// However, there are two gotchas:
// - the agentHost, agentPort split will trip on IPv6 addresses because of the colon -> we
// need to use the agentUrl
// - but the agentUrl can be unix socket and OKHttp doesn't support that so we fall back to
// http
//
// There is some magic behind the scenes where the http url will be converted to UDS if the
// target is a unix socket only
String baseUrl =
agentUrl.startsWith("unix:") ? "http://" + agentHost + ":" + agentPort : agentUrl;
return baseUrl + "/profiling/v1/input";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,19 @@ class ConfigTest extends DDSpecification {
config.getFinalProfilingUrl() == configuredUrl + "/profiling/v1/input"
}

def "uds profiling url"() {
setup:
def configuredUrl = "unix:///path/to/socket"
def props = new Properties()
props.setProperty(TRACE_AGENT_URL, configuredUrl)

when:
Config config = Config.get(props)

then:
config.getFinalProfilingUrl() == "http://" + config.getAgentHost() + ":" + config.getAgentPort() + "/profiling/v1/input"
}

def "fallback to DD_TAGS"() {
setup:
environmentVariables.set(DD_TAGS_ENV, "a:1,b:2,c:3")
Expand Down