diff --git a/instrumentation/ratpack/ratpack-1.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/RatpackForkedHttpClientTest.java b/instrumentation/ratpack/ratpack-1.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/RatpackForkedHttpClientTest.java index bb5e2be158d7..f1f12360f298 100644 --- a/instrumentation/ratpack/ratpack-1.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/RatpackForkedHttpClientTest.java +++ b/instrumentation/ratpack/ratpack-1.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/RatpackForkedHttpClientTest.java @@ -5,16 +5,9 @@ package io.opentelemetry.javaagent.instrumentation.ratpack; -import static io.opentelemetry.semconv.ServerAttributes.SERVER_ADDRESS; -import static io.opentelemetry.semconv.ServerAttributes.SERVER_PORT; - -import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.instrumentation.ratpack.client.AbstractRatpackForkedHttpClientTest; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.http.HttpClientInstrumentationExtension; -import java.net.URI; -import java.util.HashSet; -import java.util.Set; import org.junit.jupiter.api.extension.RegisterExtension; class RatpackForkedHttpClientTest extends AbstractRatpackForkedHttpClientTest { @@ -22,12 +15,4 @@ class RatpackForkedHttpClientTest extends AbstractRatpackForkedHttpClientTest { @RegisterExtension static final InstrumentationExtension testing = HttpClientInstrumentationExtension.forAgent(); - @Override - protected Set> computeHttpAttributes(URI uri) { - Set> attributes = new HashSet<>(super.computeHttpAttributes(uri)); - // underlying netty instrumentation does not provide these - attributes.remove(SERVER_ADDRESS); - attributes.remove(SERVER_PORT); - return attributes; - } } diff --git a/instrumentation/ratpack/ratpack-1.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/RatpackHttpClientTest.java b/instrumentation/ratpack/ratpack-1.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/RatpackHttpClientTest.java index 972b2f6676fe..dda378f628f8 100644 --- a/instrumentation/ratpack/ratpack-1.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/RatpackHttpClientTest.java +++ b/instrumentation/ratpack/ratpack-1.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/RatpackHttpClientTest.java @@ -5,16 +5,9 @@ package io.opentelemetry.javaagent.instrumentation.ratpack; -import static io.opentelemetry.semconv.ServerAttributes.SERVER_ADDRESS; -import static io.opentelemetry.semconv.ServerAttributes.SERVER_PORT; - -import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.instrumentation.ratpack.client.AbstractRatpackHttpClientTest; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.http.HttpClientInstrumentationExtension; -import java.net.URI; -import java.util.HashSet; -import java.util.Set; import org.junit.jupiter.api.extension.RegisterExtension; class RatpackHttpClientTest extends AbstractRatpackHttpClientTest { @@ -22,12 +15,4 @@ class RatpackHttpClientTest extends AbstractRatpackHttpClientTest { @RegisterExtension static final InstrumentationExtension testing = HttpClientInstrumentationExtension.forAgent(); - @Override - protected Set> computeHttpAttributes(URI uri) { - Set> attributes = new HashSet<>(super.computeHttpAttributes(uri)); - // underlying netty instrumentation does not provide these - attributes.remove(SERVER_ADDRESS); - attributes.remove(SERVER_PORT); - return attributes; - } } diff --git a/instrumentation/ratpack/ratpack-1.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/RatpackPooledHttpClientTest.java b/instrumentation/ratpack/ratpack-1.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/RatpackPooledHttpClientTest.java index 6a5c668b7037..77295d6b05bb 100644 --- a/instrumentation/ratpack/ratpack-1.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/RatpackPooledHttpClientTest.java +++ b/instrumentation/ratpack/ratpack-1.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/RatpackPooledHttpClientTest.java @@ -5,16 +5,9 @@ package io.opentelemetry.javaagent.instrumentation.ratpack; -import static io.opentelemetry.semconv.ServerAttributes.SERVER_ADDRESS; -import static io.opentelemetry.semconv.ServerAttributes.SERVER_PORT; - -import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.instrumentation.ratpack.client.AbstractRatpackPooledHttpClientTest; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.http.HttpClientInstrumentationExtension; -import java.net.URI; -import java.util.HashSet; -import java.util.Set; import org.junit.jupiter.api.extension.RegisterExtension; class RatpackPooledHttpClientTest extends AbstractRatpackPooledHttpClientTest { @@ -22,12 +15,4 @@ class RatpackPooledHttpClientTest extends AbstractRatpackPooledHttpClientTest { @RegisterExtension static final InstrumentationExtension testing = HttpClientInstrumentationExtension.forAgent(); - @Override - protected Set> computeHttpAttributes(URI uri) { - Set> attributes = new HashSet<>(super.computeHttpAttributes(uri)); - // underlying netty instrumentation does not provide these - attributes.remove(SERVER_ADDRESS); - attributes.remove(SERVER_PORT); - return attributes; - } } diff --git a/instrumentation/ratpack/ratpack-1.4/testing/src/main/java/io/opentelemetry/instrumentation/ratpack/client/AbstractRatpackHttpClientTest.java b/instrumentation/ratpack/ratpack-1.4/testing/src/main/java/io/opentelemetry/instrumentation/ratpack/client/AbstractRatpackHttpClientTest.java index f5626cefd2ec..3e3ed9a1f6f1 100644 --- a/instrumentation/ratpack/ratpack-1.4/testing/src/main/java/io/opentelemetry/instrumentation/ratpack/client/AbstractRatpackHttpClientTest.java +++ b/instrumentation/ratpack/ratpack-1.4/testing/src/main/java/io/opentelemetry/instrumentation/ratpack/client/AbstractRatpackHttpClientTest.java @@ -5,15 +5,20 @@ package io.opentelemetry.instrumentation.ratpack.client; +import static io.opentelemetry.semconv.ServerAttributes.SERVER_ADDRESS; +import static io.opentelemetry.semconv.ServerAttributes.SERVER_PORT; + import io.netty.channel.ConnectTimeoutException; import io.netty.handler.timeout.ReadTimeoutException; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpClientTest; import io.opentelemetry.instrumentation.testing.junit.http.HttpClientResult; import io.opentelemetry.instrumentation.testing.junit.http.HttpClientTestOptions; +import io.opentelemetry.semconv.NetworkAttributes; import java.net.URI; import java.time.Duration; import java.util.Collections; +import java.util.HashSet; import java.util.Map; import java.util.Set; import org.junit.jupiter.api.AfterAll; @@ -122,32 +127,13 @@ protected void configure(HttpClientTestOptions.Builder optionsBuilder) { .getValueOrThrow(); }); - optionsBuilder.setExpectedClientSpanNameMapper( - (uri, method) -> { - switch (uri.toString()) { - case "http://localhost:61/": // unopened port - case "https://192.0.2.1/": // non routable address - return "CONNECT"; - default: - return HttpClientTestOptions.DEFAULT_EXPECTED_CLIENT_SPAN_NAME_MAPPER.apply( - uri, method); - } - }); + if (useNettyClientAttributes()) { + optionsBuilder.setExpectedClientSpanNameMapper( + AbstractRatpackHttpClientTest::nettyExpectedClientSpanNameMapper); + } optionsBuilder.setClientSpanErrorMapper( - (uri, exception) -> { - if (uri.toString().equals("https://192.0.2.1/")) { - return new ConnectTimeoutException( - "connection timed out" - + (Boolean.getBoolean("testLatestDeps") ? " after 2000 ms" : "") - + ": /192.0.2.1:443"); - } else if (OS.WINDOWS.isCurrentOs() && uri.toString().equals("http://localhost:61/")) { - return new ConnectTimeoutException("connection timed out: localhost/127.0.0.1:61"); - } else if (uri.getPath().equals("/read-timeout")) { - return ReadTimeoutException.INSTANCE; - } - return exception; - }); + AbstractRatpackHttpClientTest::nettyClientSpanErrorMapper); optionsBuilder.setHttpAttributes(this::computeHttpAttributes); @@ -164,7 +150,45 @@ protected Set> computeHttpAttributes(URI uri) { case "https://192.0.2.1/": // non routable address return Collections.emptySet(); default: - return HttpClientTestOptions.DEFAULT_HTTP_ATTRIBUTES; + HashSet> attributes = + new HashSet<>(HttpClientTestOptions.DEFAULT_HTTP_ATTRIBUTES); + if (useNettyClientAttributes()) { + // underlying netty instrumentation does not provide these + attributes.remove(SERVER_ADDRESS); + attributes.remove(SERVER_PORT); + } else { + // ratpack client instrumentation does not provide this + attributes.remove(NetworkAttributes.NETWORK_PROTOCOL_VERSION); + } + return attributes; + } + } + + protected boolean useNettyClientAttributes() { + return true; + } + + private static Throwable nettyClientSpanErrorMapper(URI uri, Throwable exception) { + if (uri.toString().equals("https://192.0.2.1/")) { + return new ConnectTimeoutException( + "connection timed out" + + (Boolean.getBoolean("testLatestDeps") ? " after 2000 ms" : "") + + ": /192.0.2.1:443"); + } else if (OS.WINDOWS.isCurrentOs() && uri.toString().equals("http://localhost:61/")) { + return new ConnectTimeoutException("connection timed out: localhost/127.0.0.1:61"); + } else if (uri.getPath().equals("/read-timeout")) { + return ReadTimeoutException.INSTANCE; + } + return exception; + } + + private static String nettyExpectedClientSpanNameMapper(URI uri, String method) { + switch (uri.toString()) { + case "http://localhost:61/": // unopened port + case "https://192.0.2.1/": // non routable address + return "CONNECT"; + default: + return HttpClientTestOptions.DEFAULT_EXPECTED_CLIENT_SPAN_NAME_MAPPER.apply(uri, method); } } } diff --git a/instrumentation/ratpack/ratpack-1.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RatpackSingletons.java b/instrumentation/ratpack/ratpack-1.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RatpackSingletons.java index e7672f559706..8c0adac4ba75 100644 --- a/instrumentation/ratpack/ratpack-1.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RatpackSingletons.java +++ b/instrumentation/ratpack/ratpack-1.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RatpackSingletons.java @@ -11,9 +11,7 @@ import io.opentelemetry.instrumentation.netty.v4_1.internal.AttributeKeys; import io.opentelemetry.instrumentation.ratpack.v1_7.internal.ContextHolder; import io.opentelemetry.instrumentation.ratpack.v1_7.internal.OpenTelemetryHttpClient; -import io.opentelemetry.instrumentation.ratpack.v1_7.internal.OpenTelemetryServerHandler; import io.opentelemetry.instrumentation.ratpack.v1_7.internal.RatpackClientInstrumenterBuilderFactory; -import io.opentelemetry.instrumentation.ratpack.v1_7.internal.RatpackServerInstrumenterBuilderFactory; import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig; import ratpack.exec.Execution; @@ -26,25 +24,14 @@ public final class RatpackSingletons { "io.opentelemetry.ratpack-1.7", GlobalOpenTelemetry.get()) .configure(AgentCommonConfig.get()) .build()); - SERVER_HANDLER = - new OpenTelemetryServerHandler( - RatpackServerInstrumenterBuilderFactory.create( - "io.opentelemetry.ratpack-1.7", GlobalOpenTelemetry.get()) - .configure(AgentCommonConfig.get()) - .build()); } private static final OpenTelemetryHttpClient HTTP_CLIENT; - private static final OpenTelemetryServerHandler SERVER_HANDLER; public static OpenTelemetryHttpClient httpClient() { return HTTP_CLIENT; } - public static OpenTelemetryServerHandler serverHandler() { - return SERVER_HANDLER; - } - public static void propagateContextToChannel(Execution execution, Channel channel) { Context parentContext = execution diff --git a/instrumentation/ratpack/ratpack-1.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RequestActionSupportInstrumentation.java b/instrumentation/ratpack/ratpack-1.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RequestActionSupportInstrumentation.java index 16952ab1c4d4..10be05690e86 100644 --- a/instrumentation/ratpack/ratpack-1.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RequestActionSupportInstrumentation.java +++ b/instrumentation/ratpack/ratpack-1.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RequestActionSupportInstrumentation.java @@ -77,7 +77,7 @@ public static class ContextAdvice { public static Scope injectChannelAttribute( @Advice.FieldValue("execution") Execution execution) { - // Capture the CLIENT span and make it current before cally Netty layer + // Capture the CLIENT span and make it current before calling Netty layer return execution .maybeGet(ContextHolder.class) .map(ContextHolder::context) diff --git a/instrumentation/ratpack/ratpack-1.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RatpackForkedHttpClientTest.java b/instrumentation/ratpack/ratpack-1.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RatpackForkedHttpClientTest.java index 36fd784b9242..4e2e6f0a7881 100644 --- a/instrumentation/ratpack/ratpack-1.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RatpackForkedHttpClientTest.java +++ b/instrumentation/ratpack/ratpack-1.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RatpackForkedHttpClientTest.java @@ -5,19 +5,11 @@ package io.opentelemetry.javaagent.instrumentation.ratpack.v1_7; -import io.netty.channel.ConnectTimeoutException; -import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.instrumentation.ratpack.client.AbstractRatpackForkedHttpClientTest; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.http.HttpClientInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.http.HttpClientTestOptions; -import io.opentelemetry.semconv.NetworkAttributes; -import java.net.URI; -import java.util.HashSet; -import java.util.Set; -import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.api.extension.RegisterExtension; -import ratpack.http.client.HttpClientReadTimeoutException; class RatpackForkedHttpClientTest extends AbstractRatpackForkedHttpClientTest { @@ -25,28 +17,13 @@ class RatpackForkedHttpClientTest extends AbstractRatpackForkedHttpClientTest { static final InstrumentationExtension testing = HttpClientInstrumentationExtension.forAgent(); @Override - protected Set> computeHttpAttributes(URI uri) { - Set> attributes = new HashSet<>(super.computeHttpAttributes(uri)); - attributes.remove(NetworkAttributes.NETWORK_PROTOCOL_VERSION); - return attributes; + protected boolean useNettyClientAttributes() { + return false; } @Override protected void configure(HttpClientTestOptions.Builder optionsBuilder) { super.configure(optionsBuilder); - optionsBuilder.setExpectedClientSpanNameMapper( - HttpClientTestOptions.DEFAULT_EXPECTED_CLIENT_SPAN_NAME_MAPPER); - optionsBuilder.setClientSpanErrorMapper( - (uri, exception) -> { - if (uri.toString().equals("https://192.0.2.1/")) { - return new ConnectTimeoutException("Connect timeout (PT2S) connecting to " + uri); - } else if (OS.WINDOWS.isCurrentOs() && uri.toString().equals("http://localhost:61/")) { - return new ConnectTimeoutException("Connect timeout (PT2S) connecting to " + uri); - } else if (uri.getPath().equals("/read-timeout")) { - return new HttpClientReadTimeoutException( - "Read timeout (PT2S) waiting on HTTP server at " + uri); - } - return exception; - }); + optionsBuilder.setClientSpanErrorMapper(RatpackTestSingletons::ratpackClientSpanErrorMapper); } } diff --git a/instrumentation/ratpack/ratpack-1.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RatpackHttpClientTest.java b/instrumentation/ratpack/ratpack-1.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RatpackHttpClientTest.java index 4955089b76e8..43185c2d1cde 100644 --- a/instrumentation/ratpack/ratpack-1.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RatpackHttpClientTest.java +++ b/instrumentation/ratpack/ratpack-1.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RatpackHttpClientTest.java @@ -5,19 +5,11 @@ package io.opentelemetry.javaagent.instrumentation.ratpack.v1_7; -import io.netty.channel.ConnectTimeoutException; -import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.instrumentation.ratpack.client.AbstractRatpackHttpClientTest; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.http.HttpClientInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.http.HttpClientTestOptions; -import io.opentelemetry.semconv.NetworkAttributes; -import java.net.URI; -import java.util.HashSet; -import java.util.Set; -import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.api.extension.RegisterExtension; -import ratpack.http.client.HttpClientReadTimeoutException; class RatpackHttpClientTest extends AbstractRatpackHttpClientTest { @@ -25,28 +17,13 @@ class RatpackHttpClientTest extends AbstractRatpackHttpClientTest { static final InstrumentationExtension testing = HttpClientInstrumentationExtension.forAgent(); @Override - protected Set> computeHttpAttributes(URI uri) { - Set> attributes = new HashSet<>(super.computeHttpAttributes(uri)); - attributes.remove(NetworkAttributes.NETWORK_PROTOCOL_VERSION); - return attributes; + protected boolean useNettyClientAttributes() { + return false; } @Override protected void configure(HttpClientTestOptions.Builder optionsBuilder) { super.configure(optionsBuilder); - optionsBuilder.setExpectedClientSpanNameMapper( - HttpClientTestOptions.DEFAULT_EXPECTED_CLIENT_SPAN_NAME_MAPPER); - optionsBuilder.setClientSpanErrorMapper( - (uri, exception) -> { - if (uri.toString().equals("https://192.0.2.1/")) { - return new ConnectTimeoutException("Connect timeout (PT2S) connecting to " + uri); - } else if (OS.WINDOWS.isCurrentOs() && uri.toString().equals("http://localhost:61/")) { - return new ConnectTimeoutException("Connect timeout (PT2S) connecting to " + uri); - } else if (uri.getPath().equals("/read-timeout")) { - return new HttpClientReadTimeoutException( - "Read timeout (PT2S) waiting on HTTP server at " + uri); - } - return exception; - }); + optionsBuilder.setClientSpanErrorMapper(RatpackTestSingletons::ratpackClientSpanErrorMapper); } } diff --git a/instrumentation/ratpack/ratpack-1.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RatpackPooledHttpClientTest.java b/instrumentation/ratpack/ratpack-1.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RatpackPooledHttpClientTest.java index 665f157953a7..5c5d68a6438f 100644 --- a/instrumentation/ratpack/ratpack-1.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RatpackPooledHttpClientTest.java +++ b/instrumentation/ratpack/ratpack-1.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RatpackPooledHttpClientTest.java @@ -5,19 +5,11 @@ package io.opentelemetry.javaagent.instrumentation.ratpack.v1_7; -import io.netty.channel.ConnectTimeoutException; -import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.instrumentation.ratpack.client.AbstractRatpackPooledHttpClientTest; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.http.HttpClientInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.http.HttpClientTestOptions; -import io.opentelemetry.semconv.NetworkAttributes; -import java.net.URI; -import java.util.HashSet; -import java.util.Set; -import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.api.extension.RegisterExtension; -import ratpack.http.client.HttpClientReadTimeoutException; class RatpackPooledHttpClientTest extends AbstractRatpackPooledHttpClientTest { @@ -25,27 +17,13 @@ class RatpackPooledHttpClientTest extends AbstractRatpackPooledHttpClientTest { static final InstrumentationExtension testing = HttpClientInstrumentationExtension.forAgent(); @Override - protected Set> computeHttpAttributes(URI uri) { - Set> attributes = new HashSet<>(super.computeHttpAttributes(uri)); - attributes.remove(NetworkAttributes.NETWORK_PROTOCOL_VERSION); - return attributes; + protected boolean useNettyClientAttributes() { + return false; } @Override protected void configure(HttpClientTestOptions.Builder optionsBuilder) { super.configure(optionsBuilder); - optionsBuilder.setExpectedClientSpanNameMapper( - HttpClientTestOptions.DEFAULT_EXPECTED_CLIENT_SPAN_NAME_MAPPER); - optionsBuilder.setClientSpanErrorMapper( - (uri, exception) -> { - if (uri.toString().equals("https://192.0.2.1/") - || (OS.WINDOWS.isCurrentOs() && uri.toString().equals("http://localhost:61/"))) { - return new ConnectTimeoutException("Connect timeout (PT2S) connecting to " + uri); - } else if (uri.getPath().equals("/read-timeout")) { - return new HttpClientReadTimeoutException( - "Read timeout (PT2S) waiting on HTTP server at " + uri); - } - return exception; - }); + optionsBuilder.setClientSpanErrorMapper(RatpackTestSingletons::ratpackClientSpanErrorMapper); } } diff --git a/instrumentation/ratpack/ratpack-1.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RatpackTestSingletons.java b/instrumentation/ratpack/ratpack-1.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RatpackTestSingletons.java new file mode 100644 index 000000000000..63a103a93b63 --- /dev/null +++ b/instrumentation/ratpack/ratpack-1.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/ratpack/v1_7/RatpackTestSingletons.java @@ -0,0 +1,27 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.javaagent.instrumentation.ratpack.v1_7; + +import io.netty.channel.ConnectTimeoutException; +import java.net.URI; +import org.junit.jupiter.api.condition.OS; +import ratpack.http.client.HttpClientReadTimeoutException; + +public final class RatpackTestSingletons { + + private RatpackTestSingletons() {} + + public static Throwable ratpackClientSpanErrorMapper(URI uri, Throwable exception) { + if (uri.toString().equals("https://192.0.2.1/") + || (OS.WINDOWS.isCurrentOs() && uri.toString().equals("http://localhost:61/"))) { + return new ConnectTimeoutException("Connect timeout (PT2S) connecting to " + uri); + } else if (uri.getPath().equals("/read-timeout")) { + return new HttpClientReadTimeoutException( + "Read timeout (PT2S) waiting on HTTP server at " + uri); + } + return exception; + } +} diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/internal/RatpackClientInstrumenterBuilderFactory.java b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/internal/RatpackClientInstrumenterBuilderFactory.java index 37d4ea5508b3..c5a0999dea35 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/internal/RatpackClientInstrumenterBuilderFactory.java +++ b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/internal/RatpackClientInstrumenterBuilderFactory.java @@ -14,7 +14,7 @@ * This class is internal and is hence not for public use. Its APIs are unstable and can change at * any time. */ -public class RatpackClientInstrumenterBuilderFactory { +public final class RatpackClientInstrumenterBuilderFactory { private RatpackClientInstrumenterBuilderFactory() {} public static DefaultHttpClientInstrumenterBuilder create( diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/internal/RatpackServerInstrumenterBuilderFactory.java b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/internal/RatpackServerInstrumenterBuilderFactory.java index 8cce9e84928a..c0539634ab8f 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/internal/RatpackServerInstrumenterBuilderFactory.java +++ b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/internal/RatpackServerInstrumenterBuilderFactory.java @@ -14,7 +14,7 @@ * This class is internal and is hence not for public use. Its APIs are unstable and can change at * any time. */ -public class RatpackServerInstrumenterBuilderFactory { +public final class RatpackServerInstrumenterBuilderFactory { private RatpackServerInstrumenterBuilderFactory() {}