Skip to content

Commit 2663594

Browse files
committed
Fix Ratpack 1.4 connectionErrorNonRoutableAddress for TCP vs SSL failures
Only localhost TCP connection failures create CONNECT spans on Windows. Non-routable address SSL failures create method-named spans on both platforms.
1 parent 48b9c3e commit 2663594

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

instrumentation/ratpack/ratpack-1.4/testing/src/main/java/io/opentelemetry/instrumentation/ratpack/client/AbstractRatpackHttpClientTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,14 @@ private static Throwable nettyClientSpanErrorMapper(URI uri, Throwable exception
180180
}
181181

182182
// On Linux connection failures emit spans named after the attempted HTTP method, but on
183-
// Windows Netty still reports them as CONNECT. Account for both to keep the assertion
184-
// platform-agnostic.
183+
// Windows Netty still reports them as CONNECT for TCP-level failures. Account for both
184+
// to keep the assertion platform-agnostic.
185185
private static String nettyExpectedClientSpanNameMapper(URI uri, String method) {
186-
if (isWindows() && "GET".equals(method)) {
187-
String target = uri.toString();
188-
if ("http://localhost:61/".equals(target) || "https://192.0.2.1/".equals(target)) {
186+
if (isWindows() && ("GET".equals(method) || "HEAD".equals(method))) {
187+
String host = uri.getHost();
188+
// Only localhost (TCP connection refused) creates CONNECT spans on Windows
189+
// Non-routable addresses (SSL failures) create method-named spans on both platforms
190+
if ("localhost".equals(host)) {
189191
return "CONNECT";
190192
}
191193
}

0 commit comments

Comments
 (0)