Skip to content

Commit fccff88

Browse files
authored
Improve agentServiceCheck to handle scenarios where the tracer is configured to use UDS (#7098)
1 parent b2807ad commit fccff88

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

dd-trace-core/src/main/java/datadog/trace/core/StatusLogger.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import datadog.trace.api.ProductActivation;
1313
import datadog.trace.logging.LoggingSettingsDescription;
1414
import datadog.trace.util.AgentTaskScheduler;
15+
import java.io.File;
1516
import java.io.IOException;
1617
import java.lang.annotation.Annotation;
1718
import java.lang.reflect.Type;
@@ -153,11 +154,15 @@ public void toJson(JsonWriter writer, Config config) throws IOException {
153154
}
154155

155156
private static boolean agentServiceCheck(Config config) {
156-
try (Socket s = new Socket()) {
157-
s.connect(new InetSocketAddress(config.getAgentHost(), config.getAgentPort()), 500);
158-
return true;
159-
} catch (IOException ex) {
160-
return false;
157+
if (config.getAgentUrl().startsWith("unix:")) {
158+
return new File(config.getAgentUnixDomainSocket()).exists();
159+
} else {
160+
try (Socket s = new Socket()) {
161+
s.connect(new InetSocketAddress(config.getAgentHost(), config.getAgentPort()), 500);
162+
return true;
163+
} catch (IOException ex) {
164+
return false;
165+
}
161166
}
162167
}
163168

0 commit comments

Comments
 (0)