diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java index c2fa804aa2e9..21c1669c65f2 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java @@ -9,7 +9,7 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.instrumentation.api.config.Config; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.Map; import javax.annotation.Nullable; @@ -29,14 +29,14 @@ public final class PeerServiceAttributesExtractor Config.get().getMap("otel.instrumentation.common.peer-service-mapping", emptyMap()); private final Map peerServiceMapping; - private final NetClientAttributesExtractor netClientAttributesExtractor; + private final NetClientAttributesGetter attributesGetter; // visible for tests PeerServiceAttributesExtractor( Map peerServiceMapping, - NetClientAttributesExtractor netClientAttributesExtractor) { + NetClientAttributesGetter attributesGetter) { this.peerServiceMapping = peerServiceMapping; - this.netClientAttributesExtractor = netClientAttributesExtractor; + this.attributesGetter = attributesGetter; } /** @@ -44,9 +44,8 @@ public final class PeerServiceAttributesExtractor * netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute. */ public static PeerServiceAttributesExtractor create( - NetClientAttributesExtractor netAttributesExtractor) { - return new PeerServiceAttributesExtractor<>( - JAVAAGENT_PEER_SERVICE_MAPPING, netAttributesExtractor); + NetClientAttributesGetter attributesGetter) { + return new PeerServiceAttributesExtractor<>(JAVAAGENT_PEER_SERVICE_MAPPING, attributesGetter); } @Override @@ -64,10 +63,10 @@ public void onEnd( return; } - String peerName = netClientAttributesExtractor.peerName(request, response); + String peerName = attributesGetter.peerName(request, response); String peerService = mapToPeerService(peerName); if (peerService == null) { - String peerIp = netClientAttributesExtractor.peerIp(request, response); + String peerIp = attributesGetter.peerIp(request, response); peerService = mapToPeerService(peerIp); } if (peerService != null) { diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetter.java similarity index 92% rename from instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesExtractor.java rename to instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetter.java index 26e514479037..7975aa8630fb 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetter.java @@ -16,8 +16,8 @@ * {@link InetSocketAddress} so this is a convenient alternative to {@link * NetClientAttributesExtractor}. There is no meaning to implement both in the same instrumentation. */ -public abstract class InetSocketAddressNetClientAttributesExtractor - extends NetClientAttributesExtractor { +public abstract class InetSocketAddressNetClientAttributesGetter + implements NetClientAttributesGetter { @Nullable public abstract InetSocketAddress getAddress(REQUEST request, @Nullable RESPONSE response); diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractor.java index 0009f67d81e3..563fc3013eef 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractor.java @@ -14,46 +14,48 @@ * Extractor of Network * attributes. It is common to have access to {@link java.net.InetSocketAddress}, in which case - * it is more convenient to use {@link InetSocketAddressNetClientAttributesExtractor}. + * it is more convenient to use {@link InetSocketAddressNetClientAttributesGetter}. + * + *

This class delegates to a type-specific {@link NetClientAttributesGetter} for individual + * attribute extraction from request/response objects. */ -public abstract class NetClientAttributesExtractor +public final class NetClientAttributesExtractor implements AttributesExtractor { + private final NetClientAttributesGetter getter; + + public static NetClientAttributesExtractor create( + NetClientAttributesGetter getter) { + return new NetClientAttributesExtractor<>(getter); + } + + private NetClientAttributesExtractor(NetClientAttributesGetter getter) { + this.getter = getter; + } + @Override - public final void onStart(AttributesBuilder attributes, REQUEST request) {} + public void onStart(AttributesBuilder attributes, REQUEST request) {} @Override - public final void onEnd( + public void onEnd( AttributesBuilder attributes, REQUEST request, @Nullable RESPONSE response, @Nullable Throwable error) { - set(attributes, SemanticAttributes.NET_TRANSPORT, transport(request, response)); + set(attributes, SemanticAttributes.NET_TRANSPORT, getter.transport(request, response)); - String peerIp = peerIp(request, response); - String peerName = peerName(request, response); + String peerIp = getter.peerIp(request, response); + String peerName = getter.peerName(request, response); if (peerName != null && !peerName.equals(peerIp)) { set(attributes, SemanticAttributes.NET_PEER_NAME, peerName); } set(attributes, SemanticAttributes.NET_PEER_IP, peerIp); - Integer peerPort = peerPort(request, response); + Integer peerPort = getter.peerPort(request, response); if (peerPort != null && peerPort > 0) { set(attributes, SemanticAttributes.NET_PEER_PORT, (long) peerPort); } } - - @Nullable - public abstract String transport(REQUEST request, @Nullable RESPONSE response); - - @Nullable - public abstract String peerName(REQUEST request, @Nullable RESPONSE response); - - @Nullable - public abstract Integer peerPort(REQUEST request, @Nullable RESPONSE response); - - @Nullable - public abstract String peerIp(REQUEST request, @Nullable RESPONSE response); } diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesGetter.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesGetter.java new file mode 100644 index 000000000000..18d05950c165 --- /dev/null +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesGetter.java @@ -0,0 +1,31 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.api.instrumenter.net; + +import javax.annotation.Nullable; + +/** + * An interface for getting client-based network attributes. It adapts from a type-specific request + * and response into the 4 common network attribute values. + * + *

Instrumentation authors will create implementations of this interface for their specific + * library/framework. It will be used by the NetClientAttributesExtractor to obtain the various + * network attributes in a type-generic way. + */ +public interface NetClientAttributesGetter { + + @Nullable + String transport(REQUEST request, @Nullable RESPONSE response); + + @Nullable + String peerName(REQUEST request, @Nullable RESPONSE response); + + @Nullable + Integer peerPort(REQUEST request, @Nullable RESPONSE response); + + @Nullable + String peerIp(REQUEST request, @Nullable RESPONSE response); +} diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractorTest.java index 04a238451432..e2c856487f96 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractorTest.java @@ -14,7 +14,7 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.HashMap; import java.util.Map; @@ -25,7 +25,7 @@ @ExtendWith(MockitoExtension.class) class PeerServiceAttributesExtractorTest { - @Mock NetClientAttributesExtractor netAttributesExtractor; + @Mock NetClientAttributesGetter netAttributesExtractor; @Test void shouldNotSetAnyValueIfNetExtractorReturnsNulls() { diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetterTest.java similarity index 88% rename from instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesExtractorTest.java rename to instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetterTest.java index f33a1ae77406..edb7354609cd 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetterTest.java @@ -17,12 +17,11 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class InetSocketAddressNetClientAttributesExtractorTest { +class InetSocketAddressNetClientAttributesGetterTest { - private final InetSocketAddressNetClientAttributesExtractor - extractor = - new InetSocketAddressNetClientAttributesExtractor< - InetSocketAddress, InetSocketAddress>() { + private final InetSocketAddressNetClientAttributesGetter + getter = + new InetSocketAddressNetClientAttributesGetter() { @Override public InetSocketAddress getAddress( InetSocketAddress request, InetSocketAddress response) { @@ -34,9 +33,12 @@ public String transport(InetSocketAddress request, InetSocketAddress response) { return SemanticAttributes.NetTransportValues.IP_TCP; } }; + private final NetClientAttributesExtractor extractor = + NetClientAttributesExtractor.create(getter); @Test void noInetSocketAddress() { + AttributesBuilder attributes = Attributes.builder(); extractor.onEnd(attributes, null, null, null); assertThat(attributes.build()) diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractorTest.java index ff35eb24b4a8..a1709fc96c3a 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractorTest.java @@ -17,8 +17,8 @@ class NetClientAttributesExtractorTest { - static class TestNetClientAttributesExtractor - extends NetClientAttributesExtractor, Map> { + static class TestNetClientAttributesGetter + implements NetClientAttributesGetter, Map> { @Override public String transport(Map request, Map response) { @@ -64,7 +64,9 @@ void normal() { response.put("peerPort", "42"); response.put("peerIp", "4.3.2.1"); - TestNetClientAttributesExtractor extractor = new TestNetClientAttributesExtractor(); + TestNetClientAttributesGetter getter = new TestNetClientAttributesGetter(); + NetClientAttributesExtractor, Map> extractor = + NetClientAttributesExtractor.create(getter); // when AttributesBuilder startAttributes = Attributes.builder(); @@ -97,7 +99,9 @@ public void doesNotSetDuplicateAttributes() { response.put("peerPort", "42"); response.put("peerIp", "4.3.2.1"); - TestNetClientAttributesExtractor extractor = new TestNetClientAttributesExtractor(); + TestNetClientAttributesGetter getter = new TestNetClientAttributesGetter(); + NetClientAttributesExtractor, Map> extractor = + NetClientAttributesExtractor.create(getter); // when AttributesBuilder startAttributes = Attributes.builder(); @@ -124,7 +128,9 @@ public void doesNotSetNegativePort() { Map response = new HashMap<>(); response.put("peerPort", "-1"); - TestNetClientAttributesExtractor extractor = new TestNetClientAttributesExtractor(); + TestNetClientAttributesGetter getter = new TestNetClientAttributesGetter(); + NetClientAttributesExtractor, Map> extractor = + NetClientAttributesExtractor.create(getter); // when AttributesBuilder startAttributes = Attributes.builder(); diff --git a/instrumentation/akka/akka-http-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkahttp/client/AkkaHttpClientSingletons.java b/instrumentation/akka/akka-http-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkahttp/client/AkkaHttpClientSingletons.java index 034670ddf46a..a4f0891d5c02 100644 --- a/instrumentation/akka/akka-http-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkahttp/client/AkkaHttpClientSingletons.java +++ b/instrumentation/akka/akka-http-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkahttp/client/AkkaHttpClientSingletons.java @@ -14,6 +14,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.javaagent.instrumentation.akkahttp.AkkaHttpUtil; public class AkkaHttpClientSingletons { @@ -25,7 +26,7 @@ public class AkkaHttpClientSingletons { SETTER = new HttpHeaderSetter(GlobalOpenTelemetry.getPropagators()); AkkaHttpClientAttributesExtractor httpAttributesExtractor = new AkkaHttpClientAttributesExtractor(); - AkkaHttpNetAttributesExtractor netAttributesExtractor = new AkkaHttpNetAttributesExtractor(); + AkkaHttpNetAttributesGetter netAttributesGetter = new AkkaHttpNetAttributesGetter(); INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), @@ -33,8 +34,8 @@ public class AkkaHttpClientSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor)) .setSpanStatusExtractor(HttpSpanStatusExtractor.create(httpAttributesExtractor)) .addAttributesExtractor(httpAttributesExtractor) - .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(NetClientAttributesExtractor.create(netAttributesGetter)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter)) .addRequestMetrics(HttpClientMetrics.get()) .newInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/akka/akka-http-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkahttp/client/AkkaHttpNetAttributesExtractor.java b/instrumentation/akka/akka-http-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkahttp/client/AkkaHttpNetAttributesGetter.java similarity index 88% rename from instrumentation/akka/akka-http-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkahttp/client/AkkaHttpNetAttributesExtractor.java rename to instrumentation/akka/akka-http-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkahttp/client/AkkaHttpNetAttributesGetter.java index bff63739b9f7..d3614e0b20a2 100644 --- a/instrumentation/akka/akka-http-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkahttp/client/AkkaHttpNetAttributesExtractor.java +++ b/instrumentation/akka/akka-http-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkahttp/client/AkkaHttpNetAttributesGetter.java @@ -7,12 +7,12 @@ import akka.http.scaladsl.model.HttpRequest; import akka.http.scaladsl.model.HttpResponse; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; -class AkkaHttpNetAttributesExtractor - extends NetClientAttributesExtractor { +class AkkaHttpNetAttributesGetter implements NetClientAttributesGetter { + @Override public String transport(HttpRequest httpRequest, @Nullable HttpResponse httpResponse) { return SemanticAttributes.NetTransportValues.IP_TCP; diff --git a/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java b/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java index 98dc719fd711..235a9a31160f 100644 --- a/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java +++ b/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java @@ -6,13 +6,14 @@ package io.opentelemetry.instrumentation.apachedubbo.v2_7; import io.opentelemetry.api.OpenTelemetry; -import io.opentelemetry.instrumentation.apachedubbo.v2_7.internal.DubboNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.apachedubbo.v2_7.internal.DubboNetClientAttributesGetter; import io.opentelemetry.instrumentation.apachedubbo.v2_7.internal.DubboNetServerAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.rpc.RpcSpanNameExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.ArrayList; @@ -56,8 +57,9 @@ public DubboTracing build() { SpanNameExtractor spanNameExtractor = RpcSpanNameExtractor.create(rpcAttributesExtractor); - DubboNetClientAttributesExtractor netClientAttributesExtractor = - new DubboNetClientAttributesExtractor(); + DubboNetClientAttributesGetter netClientAttributesGetter = new DubboNetClientAttributesGetter(); + NetClientAttributesExtractor netClientAttributesExtractor = + NetClientAttributesExtractor.create(netClientAttributesGetter); InstrumenterBuilder serverInstrumenterBuilder = Instrumenter.builder(openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor); @@ -79,7 +81,7 @@ public DubboTracing build() { AttributesExtractor.constant(SemanticAttributes.PEER_SERVICE, peerService)); } else { clientInstrumenterBuilder.addAttributesExtractor( - PeerServiceAttributesExtractor.create(netClientAttributesExtractor)); + PeerServiceAttributesExtractor.create(netClientAttributesGetter)); } return new DubboTracing( diff --git a/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetClientAttributesExtractor.java b/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetClientAttributesGetter.java similarity index 79% rename from instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetClientAttributesExtractor.java rename to instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetClientAttributesGetter.java index 309850004110..e1fb6bfc26c0 100644 --- a/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetClientAttributesExtractor.java +++ b/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetClientAttributesGetter.java @@ -6,13 +6,13 @@ package io.opentelemetry.instrumentation.apachedubbo.v2_7.internal; import io.opentelemetry.instrumentation.apachedubbo.v2_7.DubboRequest; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter; import java.net.InetSocketAddress; import javax.annotation.Nullable; import org.apache.dubbo.rpc.Result; -public final class DubboNetClientAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { +public final class DubboNetClientAttributesGetter + extends InetSocketAddressNetClientAttributesGetter { @Override @Nullable diff --git a/instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientNetAttributesExtractor.java b/instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientNetAttributesGetter.java similarity index 87% rename from instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientNetAttributesExtractor.java rename to instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientNetAttributesGetter.java index e39feb2dedd7..68c20fe7d854 100644 --- a/instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientNetAttributesExtractor.java +++ b/instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientNetAttributesGetter.java @@ -5,13 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpasyncclient; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; import org.apache.http.HttpResponse; -final class ApacheHttpAsyncClientNetAttributesExtractor - extends NetClientAttributesExtractor { +final class ApacheHttpAsyncClientNetAttributesGetter + implements NetClientAttributesGetter { @Override public String transport(ApacheHttpClientRequest request, @Nullable HttpResponse response) { diff --git a/instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientSingletons.java b/instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientSingletons.java index f2ef538999ac..37ffbe8da812 100644 --- a/instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientSingletons.java +++ b/instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientSingletons.java @@ -14,6 +14,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import org.apache.http.HttpResponse; public final class ApacheHttpAsyncClientSingletons { @@ -28,8 +29,10 @@ public final class ApacheHttpAsyncClientSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - ApacheHttpAsyncClientNetAttributesExtractor netAttributesExtractor = - new ApacheHttpAsyncClientNetAttributesExtractor(); + ApacheHttpAsyncClientNetAttributesGetter netAttributesGetter = + new ApacheHttpAsyncClientNetAttributesGetter(); + NetClientAttributesExtractor netAttributesExtractor = + NetClientAttributesExtractor.create(netAttributesGetter); INSTRUMENTER = Instrumenter.builder( @@ -37,7 +40,7 @@ public final class ApacheHttpAsyncClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(HttpHeaderSetter.INSTANCE); } diff --git a/instrumentation/apache-httpclient/apache-httpclient-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v2_0/ApacheHttpClientNetAttributesExtractor.java b/instrumentation/apache-httpclient/apache-httpclient-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v2_0/ApacheHttpClientNetAttributesGetter.java similarity index 89% rename from instrumentation/apache-httpclient/apache-httpclient-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v2_0/ApacheHttpClientNetAttributesExtractor.java rename to instrumentation/apache-httpclient/apache-httpclient-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v2_0/ApacheHttpClientNetAttributesGetter.java index 2a5052f88169..ecda03fac812 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v2_0/ApacheHttpClientNetAttributesExtractor.java +++ b/instrumentation/apache-httpclient/apache-httpclient-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v2_0/ApacheHttpClientNetAttributesGetter.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; import org.apache.commons.httpclient.HostConfiguration; import org.apache.commons.httpclient.HttpMethod; -final class ApacheHttpClientNetAttributesExtractor - extends NetClientAttributesExtractor { +final class ApacheHttpClientNetAttributesGetter + implements NetClientAttributesGetter { @Override public String transport(HttpMethod request, @Nullable HttpMethod response) { diff --git a/instrumentation/apache-httpclient/apache-httpclient-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v2_0/ApacheHttpClientSingletons.java b/instrumentation/apache-httpclient/apache-httpclient-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v2_0/ApacheHttpClientSingletons.java index 57be8ea53bdf..302004360852 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v2_0/ApacheHttpClientSingletons.java +++ b/instrumentation/apache-httpclient/apache-httpclient-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v2_0/ApacheHttpClientSingletons.java @@ -14,6 +14,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import org.apache.commons.httpclient.HttpMethod; public final class ApacheHttpClientSingletons { @@ -28,16 +29,15 @@ public final class ApacheHttpClientSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - ApacheHttpClientNetAttributesExtractor netAttributesExtractor = - new ApacheHttpClientNetAttributesExtractor(); - + ApacheHttpClientNetAttributesGetter netAttributesGetter = + new ApacheHttpClientNetAttributesGetter(); INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanNameExtractor) .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) - .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(NetClientAttributesExtractor.create(netAttributesGetter)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(HttpHeaderSetter.INSTANCE); } diff --git a/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v4_0/ApacheHttpClientNetAttributesExtractor.java b/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v4_0/ApacheHttpClientNetAttributesGetter.java similarity index 87% rename from instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v4_0/ApacheHttpClientNetAttributesExtractor.java rename to instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v4_0/ApacheHttpClientNetAttributesGetter.java index 2a7f503d92b7..dfe289d7eafa 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v4_0/ApacheHttpClientNetAttributesExtractor.java +++ b/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v4_0/ApacheHttpClientNetAttributesGetter.java @@ -5,13 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v4_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; import org.apache.http.HttpResponse; -final class ApacheHttpClientNetAttributesExtractor - extends NetClientAttributesExtractor { +final class ApacheHttpClientNetAttributesGetter + implements NetClientAttributesGetter { @Override public String transport(ApacheHttpClientRequest request, @Nullable HttpResponse response) { diff --git a/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v4_0/ApacheHttpClientSingletons.java b/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v4_0/ApacheHttpClientSingletons.java index 88b0b5aa9648..9a5faecbf4a6 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v4_0/ApacheHttpClientSingletons.java +++ b/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v4_0/ApacheHttpClientSingletons.java @@ -14,6 +14,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import org.apache.http.HttpResponse; public final class ApacheHttpClientSingletons { @@ -28,15 +29,15 @@ public final class ApacheHttpClientSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - ApacheHttpClientNetAttributesExtractor netAttributesExtractor = - new ApacheHttpClientNetAttributesExtractor(); + ApacheHttpClientNetAttributesGetter netAttributesExtractor = + new ApacheHttpClientNetAttributesGetter(); INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanNameExtractor) .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) - .addAttributesExtractor(netAttributesExtractor) + .addAttributesExtractor(NetClientAttributesExtractor.create(netAttributesExtractor)) .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(HttpHeaderSetter.INSTANCE); diff --git a/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientNetAttributesExtractor.java b/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientNetAttributesGetter.java similarity index 87% rename from instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientNetAttributesExtractor.java rename to instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientNetAttributesGetter.java index e7455d43ae97..2e1b1b8df869 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientNetAttributesExtractor.java +++ b/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientNetAttributesGetter.java @@ -5,13 +5,13 @@ package io.opentelemetry.instrumentation.apachehttpclient.v4_3; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; import org.apache.http.HttpResponse; -final class ApacheHttpClientNetAttributesExtractor - extends NetClientAttributesExtractor { +final class ApacheHttpClientNetAttributesGetter + implements NetClientAttributesGetter { @Override public String transport(ApacheHttpClientRequest request, @Nullable HttpResponse response) { diff --git a/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientTracingBuilder.java b/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientTracingBuilder.java index 22443988ecaf..a49a9de423d9 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientTracingBuilder.java +++ b/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientTracingBuilder.java @@ -16,6 +16,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import java.util.ArrayList; import java.util.List; import org.apache.http.HttpResponse; @@ -70,14 +71,14 @@ public ApacheHttpClientTracing build() { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - ApacheHttpClientNetAttributesExtractor netAttributesExtractor = - new ApacheHttpClientNetAttributesExtractor(); + ApacheHttpClientNetAttributesGetter netAttributesGetter = + new ApacheHttpClientNetAttributesGetter(); Instrumenter instrumenter = Instrumenter.builder( openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor) .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) - .addAttributesExtractor(netAttributesExtractor) + .addAttributesExtractor(NetClientAttributesExtractor.create(netAttributesGetter)) .addAttributesExtractors(additionalExtractors) // We manually inject because we need to inject internal requests for redirects. .newInstrumenter(SpanKindExtractor.alwaysClient()); diff --git a/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientNetAttributesExtractor.java b/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientNetAttributesGetter.java similarity index 87% rename from instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientNetAttributesExtractor.java rename to instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientNetAttributesGetter.java index ff080fe947d2..fa2207cb916f 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientNetAttributesExtractor.java +++ b/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientNetAttributesGetter.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v5_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; import org.apache.hc.core5.http.ClassicHttpRequest; @@ -13,11 +13,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -final class ApacheHttpClientNetAttributesExtractor - extends NetClientAttributesExtractor { +final class ApacheHttpClientNetAttributesGetter + implements NetClientAttributesGetter { private static final Logger logger = - LoggerFactory.getLogger(ApacheHttpClientNetAttributesExtractor.class); + LoggerFactory.getLogger(ApacheHttpClientNetAttributesGetter.class); @Override public String transport(ClassicHttpRequest request, @Nullable HttpResponse response) { diff --git a/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientSingletons.java b/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientSingletons.java index 44063e9ab82a..548ac8fba8fe 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientSingletons.java +++ b/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientSingletons.java @@ -14,6 +14,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.HttpResponse; @@ -29,15 +30,15 @@ public final class ApacheHttpClientSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - ApacheHttpClientNetAttributesExtractor netAttributesExtractor = - new ApacheHttpClientNetAttributesExtractor(); + ApacheHttpClientNetAttributesGetter netAttributesExtractor = + new ApacheHttpClientNetAttributesGetter(); INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanNameExtractor) .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) - .addAttributesExtractor(netAttributesExtractor) + .addAttributesExtractor(NetClientAttributesExtractor.create(netAttributesExtractor)) .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(HttpHeaderSetter.INSTANCE); diff --git a/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaNetClientAttributesExtractor.java b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaNetClientAttributesGetter.java similarity index 83% rename from instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaNetClientAttributesExtractor.java rename to instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaNetClientAttributesGetter.java index f96758b59bbe..b5cd4d735d0f 100644 --- a/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaNetClientAttributesExtractor.java +++ b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaNetClientAttributesGetter.java @@ -7,14 +7,14 @@ import com.linecorp.armeria.common.RequestContext; import com.linecorp.armeria.common.logging.RequestLog; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import java.net.SocketAddress; import javax.annotation.Nullable; -final class ArmeriaNetClientAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { +final class ArmeriaNetClientAttributesGetter + extends InetSocketAddressNetClientAttributesGetter { @Override public String transport(RequestContext ctx, @Nullable RequestLog requestLog) { diff --git a/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaTracingBuilder.java b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaTracingBuilder.java index 78abd7741c8c..7513aa5db11c 100644 --- a/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaTracingBuilder.java +++ b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaTracingBuilder.java @@ -21,6 +21,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.instrumentation.api.server.ServerSpanNaming; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.ArrayList; @@ -120,8 +121,10 @@ public ArmeriaTracing build() { Stream.of(clientInstrumenterBuilder, serverInstrumenterBuilder) .forEach(instrumenter -> instrumenter.addAttributesExtractors(additionalExtractors)); - ArmeriaNetClientAttributesExtractor netClientAttributesExtractor = - new ArmeriaNetClientAttributesExtractor(); + ArmeriaNetClientAttributesGetter netClientAttributesGetter = + new ArmeriaNetClientAttributesGetter(); + NetClientAttributesExtractor netClientAttributesExtractor = + NetClientAttributesExtractor.create(netClientAttributesGetter); clientInstrumenterBuilder .setSpanStatusExtractor( @@ -144,7 +147,7 @@ public ArmeriaTracing build() { AttributesExtractor.constant(SemanticAttributes.PEER_SERVICE, peerService)); } else { clientInstrumenterBuilder.addAttributesExtractor( - PeerServiceAttributesExtractor.create(netClientAttributesExtractor)); + PeerServiceAttributesExtractor.create(netClientAttributesGetter)); } return new ArmeriaTracing( diff --git a/instrumentation/async-http-client/async-http-client-1.9/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v1_9/AsyncHttpClientNetAttributesExtractor.java b/instrumentation/async-http-client/async-http-client-1.9/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v1_9/AsyncHttpClientNetAttributesGetter.java similarity index 86% rename from instrumentation/async-http-client/async-http-client-1.9/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v1_9/AsyncHttpClientNetAttributesExtractor.java rename to instrumentation/async-http-client/async-http-client-1.9/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v1_9/AsyncHttpClientNetAttributesGetter.java index 5ba2f1b6d162..294f6c6e7d33 100644 --- a/instrumentation/async-http-client/async-http-client-1.9/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v1_9/AsyncHttpClientNetAttributesExtractor.java +++ b/instrumentation/async-http-client/async-http-client-1.9/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v1_9/AsyncHttpClientNetAttributesGetter.java @@ -7,12 +7,12 @@ import com.ning.http.client.Request; import com.ning.http.client.Response; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; -final class AsyncHttpClientNetAttributesExtractor - extends NetClientAttributesExtractor { +final class AsyncHttpClientNetAttributesGetter + implements NetClientAttributesGetter { @Override public String transport(Request request, @Nullable Response response) { diff --git a/instrumentation/async-http-client/async-http-client-1.9/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v1_9/AsyncHttpClientSingletons.java b/instrumentation/async-http-client/async-http-client-1.9/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v1_9/AsyncHttpClientSingletons.java index 489d97ad9094..bce983cc964b 100644 --- a/instrumentation/async-http-client/async-http-client-1.9/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v1_9/AsyncHttpClientSingletons.java +++ b/instrumentation/async-http-client/async-http-client-1.9/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v1_9/AsyncHttpClientSingletons.java @@ -16,6 +16,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; public final class AsyncHttpClientSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.async-http-client-1.9"; @@ -29,16 +30,17 @@ public final class AsyncHttpClientSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - AsyncHttpClientNetAttributesExtractor netAttributesExtractor = - new AsyncHttpClientNetAttributesExtractor(); - + AsyncHttpClientNetAttributesGetter netAttributesGetter = + new AsyncHttpClientNetAttributesGetter(); + NetClientAttributesExtractor netAttributesExtractor = + NetClientAttributesExtractor.create(netAttributesGetter); INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanNameExtractor) .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(HttpHeaderSetter.INSTANCE); } diff --git a/instrumentation/async-http-client/async-http-client-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v2_0/AsyncHttpClientNetAttributesExtractor.java b/instrumentation/async-http-client/async-http-client-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v2_0/AsyncHttpClientNetAttributesGetter.java similarity index 82% rename from instrumentation/async-http-client/async-http-client-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v2_0/AsyncHttpClientNetAttributesExtractor.java rename to instrumentation/async-http-client/async-http-client-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v2_0/AsyncHttpClientNetAttributesGetter.java index dd942203e872..3f720975e7bb 100644 --- a/instrumentation/async-http-client/async-http-client-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v2_0/AsyncHttpClientNetAttributesExtractor.java +++ b/instrumentation/async-http-client/async-http-client-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v2_0/AsyncHttpClientNetAttributesGetter.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.asynchttpclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import javax.annotation.Nullable; import org.asynchttpclient.Response; -final class AsyncHttpClientNetAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { +final class AsyncHttpClientNetAttributesGetter + extends InetSocketAddressNetClientAttributesGetter { @Override public String transport(RequestContext request, @Nullable Response response) { diff --git a/instrumentation/async-http-client/async-http-client-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v2_0/AsyncHttpClientSingletons.java b/instrumentation/async-http-client/async-http-client-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v2_0/AsyncHttpClientSingletons.java index d019b056abff..f88c890ec9b8 100644 --- a/instrumentation/async-http-client/async-http-client-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v2_0/AsyncHttpClientSingletons.java +++ b/instrumentation/async-http-client/async-http-client-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v2_0/AsyncHttpClientSingletons.java @@ -29,8 +29,10 @@ public final class AsyncHttpClientSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); + AsyncHttpClientNetAttributesGetter netAttributeGetter = + new AsyncHttpClientNetAttributesGetter(); NetClientAttributesExtractor netAttributesExtractor = - new AsyncHttpClientNetAttributesExtractor(); + NetClientAttributesExtractor.create(netAttributeGetter); INSTRUMENTER = Instrumenter.builder( @@ -38,7 +40,7 @@ public final class AsyncHttpClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributeGetter)) .addAttributesExtractor(new AsyncHttpClientAdditionalAttributesExtractor()) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(HttpHeaderSetter.INSTANCE); diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkInstrumenterFactory.java b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkInstrumenterFactory.java index c90874a6338f..2a2d742dc1ff 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkInstrumenterFactory.java +++ b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkInstrumenterFactory.java @@ -11,6 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import java.util.Arrays; import java.util.List; @@ -21,8 +22,8 @@ final class AwsSdkInstrumenterFactory { new AwsSdkHttpAttributesExtractor(); private static final AwsSdkRpcAttributesExtractor rpcAttributesExtractor = new AwsSdkRpcAttributesExtractor(); - private static final AwsSdkNetAttributesExtractor netAttributesExtractor = - new AwsSdkNetAttributesExtractor(); + private static final AttributesExtractor, Response> netAttributesExtractor = + NetClientAttributesExtractor.create(new AwsSdkNetAttributesGetter()); private static final AwsSdkExperimentalAttributesExtractor experimentalAttributesExtractor = new AwsSdkExperimentalAttributesExtractor(); private static final AwsSdkSpanKindExtractor spanKindExtractor = new AwsSdkSpanKindExtractor(); diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkNetAttributesExtractor.java b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkNetAttributesGetter.java similarity index 88% rename from instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkNetAttributesExtractor.java rename to instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkNetAttributesGetter.java index e8439919a47e..ee9ec7584106 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkNetAttributesExtractor.java +++ b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkNetAttributesGetter.java @@ -7,11 +7,12 @@ import com.amazonaws.Request; import com.amazonaws.Response; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; -class AwsSdkNetAttributesExtractor extends NetClientAttributesExtractor, Response> { +class AwsSdkNetAttributesGetter implements NetClientAttributesGetter, Response> { + @Override public String transport(Request request, @Nullable Response response) { return SemanticAttributes.NetTransportValues.IP_TCP; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkInstrumenterFactory.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkInstrumenterFactory.java index 3ae4d9d1c238..c42fc5c7c1f2 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkInstrumenterFactory.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkInstrumenterFactory.java @@ -9,6 +9,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import java.util.Arrays; import java.util.List; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; @@ -21,8 +22,10 @@ final class AwsSdkInstrumenterFactory { new AwsSdkHttpAttributesExtractor(); static final AwsSdkRpcAttributesExtractor rpcAttributesExtractor = new AwsSdkRpcAttributesExtractor(); - private static final AwsSdkNetAttributesExtractor netAttributesExtractor = - new AwsSdkNetAttributesExtractor(); + private static final AwsSdkNetAttributesGetter netAttributesGetter = + new AwsSdkNetAttributesGetter(); + private static final NetClientAttributesExtractor + netAttributesExtractor = NetClientAttributesExtractor.create(netAttributesGetter); private static final AwsSdkExperimentalAttributesExtractor experimentalAttributesExtractor = new AwsSdkExperimentalAttributesExtractor(); diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkNetAttributesExtractor.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkNetAttributesGetter.java similarity index 91% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkNetAttributesExtractor.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkNetAttributesGetter.java index 7b19616dd851..32e89a3f791b 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkNetAttributesExtractor.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkNetAttributesGetter.java @@ -5,15 +5,16 @@ package io.opentelemetry.instrumentation.awssdk.v2_2; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; import software.amazon.awssdk.http.SdkHttpRequest; import software.amazon.awssdk.http.SdkHttpResponse; -class AwsSdkNetAttributesExtractor - extends NetClientAttributesExtractor { +class AwsSdkNetAttributesGetter + implements NetClientAttributesGetter { + @Override public String transport(ExecutionAttributes request, @Nullable SdkHttpResponse response) { return SemanticAttributes.NetTransportValues.IP_TCP; diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraNetAttributesExtractor.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraNetAttributesGetter.java similarity index 79% rename from instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraNetAttributesExtractor.java rename to instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraNetAttributesGetter.java index 80833176ce75..c8b625e588c9 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraNetAttributesExtractor.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraNetAttributesGetter.java @@ -6,12 +6,12 @@ package io.opentelemetry.javaagent.instrumentation.cassandra.v3_0; import com.datastax.driver.core.ExecutionInfo; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter; import java.net.InetSocketAddress; import javax.annotation.Nullable; -final class CassandraNetAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { +final class CassandraNetAttributesGetter + extends InetSocketAddressNetClientAttributesGetter { @Override @Nullable diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSingletons.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSingletons.java index 86fc2c55102a..038d927b10e4 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSingletons.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSingletons.java @@ -12,6 +12,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbSpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; public final class CassandraSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.cassandra-3.0"; @@ -29,7 +30,8 @@ public final class CassandraSingletons { Instrumenter.builder( GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanName) .addAttributesExtractor(attributesExtractor) - .addAttributesExtractor(new CassandraNetAttributesExtractor()) + .addAttributesExtractor( + NetClientAttributesExtractor.create(new CassandraNetAttributesGetter())) .newInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraNetAttributesExtractor.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraNetAttributesGetter.java similarity index 86% rename from instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraNetAttributesExtractor.java rename to instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraNetAttributesGetter.java index 2ff5151501d8..cb58a2a6d434 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraNetAttributesExtractor.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraNetAttributesGetter.java @@ -7,13 +7,13 @@ import com.datastax.oss.driver.api.core.cql.ExecutionInfo; import com.datastax.oss.driver.api.core.metadata.Node; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter; import java.net.InetSocketAddress; import java.net.SocketAddress; import javax.annotation.Nullable; -final class CassandraNetAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { +final class CassandraNetAttributesGetter + extends InetSocketAddressNetClientAttributesGetter { @Override @Nullable diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSingletons.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSingletons.java index f2840b3162ba..85082e7d12f9 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSingletons.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSingletons.java @@ -12,6 +12,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbSpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; public final class CassandraSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.cassandra-4.0"; @@ -28,7 +29,8 @@ public final class CassandraSingletons { Instrumenter.builder( GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanName) .addAttributesExtractor(attributesExtractor) - .addAttributesExtractor(new CassandraNetAttributesExtractor()) + .addAttributesExtractor( + NetClientAttributesExtractor.create(new CassandraNetAttributesGetter())) .addAttributesExtractor(new CassandraAttributesExtractor()) .newInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestInstrumenterFactory.java b/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestInstrumenterFactory.java index 0700357ec4c0..91d10a5625b2 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestInstrumenterFactory.java +++ b/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestInstrumenterFactory.java @@ -11,6 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbSpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import org.elasticsearch.client.Response; public final class ElasticsearchRestInstrumenterFactory { @@ -19,14 +20,16 @@ public static Instrumenter create(String instrumentationName) ElasticsearchRestAttributesExtractor attributesExtractor = new ElasticsearchRestAttributesExtractor(); SpanNameExtractor spanNameExtractor = DbSpanNameExtractor.create(attributesExtractor); - ElasticsearchRestNetResponseAttributesExtractor netAttributesExtractor = - new ElasticsearchRestNetResponseAttributesExtractor(); + ElasticsearchRestNetResponseAttributesGetter netAttributesGetter = + new ElasticsearchRestNetResponseAttributesGetter(); + NetClientAttributesExtractor netAttributesExtractor = + NetClientAttributesExtractor.create(netAttributesGetter); return Instrumenter.builder( GlobalOpenTelemetry.get(), instrumentationName, spanNameExtractor) .addAttributesExtractor(attributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter)) .newInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestNetResponseAttributesExtractor.java b/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestNetResponseAttributesGetter.java similarity index 88% rename from instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestNetResponseAttributesExtractor.java rename to instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestNetResponseAttributesGetter.java index cb56ce1f63a5..b61a263d5adf 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestNetResponseAttributesExtractor.java +++ b/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestNetResponseAttributesGetter.java @@ -5,13 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.rest; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; import org.elasticsearch.client.Response; -final class ElasticsearchRestNetResponseAttributesExtractor - extends NetClientAttributesExtractor { +final class ElasticsearchRestNetResponseAttributesGetter + implements NetClientAttributesGetter { + @Override public String transport(String operation, Response response) { return SemanticAttributes.NetTransportValues.IP_TCP; diff --git a/instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_0/Elasticsearch5TransportSingletons.java b/instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_0/Elasticsearch5TransportSingletons.java index 758330b64933..7980678389ef 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_0/Elasticsearch5TransportSingletons.java +++ b/instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_0/Elasticsearch5TransportSingletons.java @@ -6,7 +6,8 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.v5_0; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportNetResponseAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportNetResponseAttributesGetter; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportRequest; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticsearchTransportInstrumenterFactory; import org.elasticsearch.action.ActionResponse; @@ -17,7 +18,7 @@ public final class Elasticsearch5TransportSingletons { ElasticsearchTransportInstrumenterFactory.create( "io.opentelemetry.elasticsearch-transport-5.0", new Elasticsearch5TransportExperimentalAttributesExtractor(), - new ElasticTransportNetResponseAttributesExtractor()); + NetClientAttributesExtractor.create(new ElasticTransportNetResponseAttributesGetter())); public static Instrumenter instrumenter() { return INSTRUMENTER; diff --git a/instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_3/Elasticsearch53TransportSingletons.java b/instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_3/Elasticsearch53TransportSingletons.java index 8b0183eaa1b1..215ef95e029f 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_3/Elasticsearch53TransportSingletons.java +++ b/instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_3/Elasticsearch53TransportSingletons.java @@ -6,7 +6,8 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.v5_3; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportNetResponseAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportNetResponseAttributesGetter; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportRequest; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticsearchTransportInstrumenterFactory; import org.elasticsearch.action.ActionResponse; @@ -17,7 +18,7 @@ public final class Elasticsearch53TransportSingletons { ElasticsearchTransportInstrumenterFactory.create( "io.opentelemetry.elasticsearch-transport-5.3", new Elasticsearch53TransportExperimentalAttributesExtractor(), - new ElasticTransportNetResponseAttributesExtractor()); + NetClientAttributesExtractor.create(new ElasticTransportNetResponseAttributesGetter())); public static Instrumenter instrumenter() { return INSTRUMENTER; diff --git a/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/Elasticsearch6TransportNetAttributesExtractor.java b/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/Elasticsearch6TransportNetAttributesGetter.java similarity index 81% rename from instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/Elasticsearch6TransportNetAttributesExtractor.java rename to instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/Elasticsearch6TransportNetAttributesGetter.java index f7123320e07b..5374fe27fbab 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/Elasticsearch6TransportNetAttributesExtractor.java +++ b/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/Elasticsearch6TransportNetAttributesGetter.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.v6_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportRequest; import java.net.InetSocketAddress; import javax.annotation.Nullable; import org.elasticsearch.action.ActionResponse; -public class Elasticsearch6TransportNetAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { +public class Elasticsearch6TransportNetAttributesGetter + extends InetSocketAddressNetClientAttributesGetter { @Override @Nullable public String transport(ElasticTransportRequest request, @Nullable ActionResponse response) { diff --git a/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/Elasticsearch6TransportSingletons.java b/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/Elasticsearch6TransportSingletons.java index 47ff83056ab7..5e72056bb4f8 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/Elasticsearch6TransportSingletons.java +++ b/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/Elasticsearch6TransportSingletons.java @@ -6,6 +6,7 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.v6_0; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportRequest; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticsearchTransportInstrumenterFactory; import org.elasticsearch.action.ActionResponse; @@ -16,7 +17,7 @@ public final class Elasticsearch6TransportSingletons { ElasticsearchTransportInstrumenterFactory.create( "io.opentelemetry.elasticsearch-transport-6.0", new Elasticsearch6TransportExperimentalAttributesExtractor(), - new Elasticsearch6TransportNetAttributesExtractor()); + NetClientAttributesExtractor.create(new Elasticsearch6TransportNetAttributesGetter())); public static Instrumenter instrumenter() { return INSTRUMENTER; diff --git a/instrumentation/elasticsearch/elasticsearch-transport-common/library/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetResponseAttributesExtractor.java b/instrumentation/elasticsearch/elasticsearch-transport-common/library/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetResponseAttributesGetter.java similarity index 89% rename from instrumentation/elasticsearch/elasticsearch-transport-common/library/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetResponseAttributesExtractor.java rename to instrumentation/elasticsearch/elasticsearch-transport-common/library/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetResponseAttributesGetter.java index 69719c5b9b19..4af4dd83c4a4 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-common/library/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetResponseAttributesExtractor.java +++ b/instrumentation/elasticsearch/elasticsearch-transport-common/library/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetResponseAttributesGetter.java @@ -5,12 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import javax.annotation.Nullable; import org.elasticsearch.action.ActionResponse; -public class ElasticTransportNetResponseAttributesExtractor - extends NetClientAttributesExtractor { +public class ElasticTransportNetResponseAttributesGetter + implements NetClientAttributesGetter { + @Override @Nullable public String transport(ElasticTransportRequest request, @Nullable ActionResponse response) { diff --git a/instrumentation/google-http-client-1.19/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/googlehttpclient/GoogleHttpClientNetAttributesExtractor.java b/instrumentation/google-http-client-1.19/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/googlehttpclient/GoogleHttpClientNetAttributesGetter.java similarity index 88% rename from instrumentation/google-http-client-1.19/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/googlehttpclient/GoogleHttpClientNetAttributesExtractor.java rename to instrumentation/google-http-client-1.19/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/googlehttpclient/GoogleHttpClientNetAttributesGetter.java index f67e11128ff5..36ab5e41b707 100644 --- a/instrumentation/google-http-client-1.19/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/googlehttpclient/GoogleHttpClientNetAttributesExtractor.java +++ b/instrumentation/google-http-client-1.19/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/googlehttpclient/GoogleHttpClientNetAttributesGetter.java @@ -7,12 +7,12 @@ import com.google.api.client.http.HttpRequest; import com.google.api.client.http.HttpResponse; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; -final class GoogleHttpClientNetAttributesExtractor - extends NetClientAttributesExtractor { +final class GoogleHttpClientNetAttributesGetter + implements NetClientAttributesGetter { @Override public String transport(HttpRequest request, @Nullable HttpResponse response) { diff --git a/instrumentation/google-http-client-1.19/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/googlehttpclient/GoogleHttpClientSingletons.java b/instrumentation/google-http-client-1.19/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/googlehttpclient/GoogleHttpClientSingletons.java index 12cea421ebda..d17cde971a94 100644 --- a/instrumentation/google-http-client-1.19/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/googlehttpclient/GoogleHttpClientSingletons.java +++ b/instrumentation/google-http-client-1.19/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/googlehttpclient/GoogleHttpClientSingletons.java @@ -16,6 +16,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; public class GoogleHttpClientSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.google-http-client-1.19"; @@ -29,8 +30,10 @@ public class GoogleHttpClientSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - GoogleHttpClientNetAttributesExtractor netAttributesExtractor = - new GoogleHttpClientNetAttributesExtractor(); + GoogleHttpClientNetAttributesGetter netAttributesGetter = + new GoogleHttpClientNetAttributesGetter(); + NetClientAttributesExtractor netAttributesExtractor = + NetClientAttributesExtractor.create(netAttributesGetter); INSTRUMENTER = Instrumenter.builder( @@ -38,7 +41,7 @@ public class GoogleHttpClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(HttpHeaderSetter.INSTANCE); } diff --git a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/GrpcTracingBuilder.java b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/GrpcTracingBuilder.java index f60207ee34bc..5563dccb34b7 100644 --- a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/GrpcTracingBuilder.java +++ b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/GrpcTracingBuilder.java @@ -12,7 +12,8 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; -import io.opentelemetry.instrumentation.grpc.v1_6.internal.GrpcNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.grpc.v1_6.internal.GrpcNetClientAttributesGetter; import io.opentelemetry.instrumentation.grpc.v1_6.internal.GrpcNetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.ArrayList; @@ -79,10 +80,11 @@ public GrpcTracing build() { new GrpcRpcAttributesExtractor(), new GrpcAttributesExtractor()) .addAttributesExtractors(additionalExtractors)); - GrpcNetClientAttributesExtractor netClientAttributesExtractor = - new GrpcNetClientAttributesExtractor(); + GrpcNetClientAttributesGetter netClientAttributesExtractor = + new GrpcNetClientAttributesGetter(); - clientInstrumenterBuilder.addAttributesExtractor(netClientAttributesExtractor); + clientInstrumenterBuilder.addAttributesExtractor( + NetClientAttributesExtractor.create(netClientAttributesExtractor)); serverInstrumenterBuilder.addAttributesExtractor(new GrpcNetServerAttributesExtractor()); if (peerService != null) { diff --git a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetClientAttributesExtractor.java b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetClientAttributesGetter.java similarity index 83% rename from instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetClientAttributesExtractor.java rename to instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetClientAttributesGetter.java index ff8f5a3192df..5d38bf624dbf 100644 --- a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetClientAttributesExtractor.java +++ b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetClientAttributesGetter.java @@ -6,15 +6,15 @@ package io.opentelemetry.instrumentation.grpc.v1_6.internal; import io.grpc.Status; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter; import io.opentelemetry.instrumentation.grpc.v1_6.GrpcRequest; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import java.net.SocketAddress; import javax.annotation.Nullable; -public final class GrpcNetClientAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { +public final class GrpcNetClientAttributesGetter + extends InetSocketAddressNetClientAttributesGetter { @Override @Nullable public InetSocketAddress getAddress(GrpcRequest request, @Nullable Status response) { diff --git a/instrumentation/http-url-connection/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpurlconnection/HttpUrlConnectionSingletons.java b/instrumentation/http-url-connection/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpurlconnection/HttpUrlConnectionSingletons.java index d884aaf63e75..7d1b67514ff9 100644 --- a/instrumentation/http-url-connection/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpurlconnection/HttpUrlConnectionSingletons.java +++ b/instrumentation/http-url-connection/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpurlconnection/HttpUrlConnectionSingletons.java @@ -11,6 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import java.net.HttpURLConnection; public class HttpUrlConnectionSingletons { @@ -19,10 +20,12 @@ public class HttpUrlConnectionSingletons { static { HttpUrlHttpAttributesExtractor httpAttributesExtractor = new HttpUrlHttpAttributesExtractor(); - HttpUrlNetAttributesExtractor netAttributesExtractor = new HttpUrlNetAttributesExtractor(); + HttpUrlNetAttributesGetter netAttributesGetter = new HttpUrlNetAttributesGetter(); SpanNameExtractor spanNameExtractor = HttpSpanNameExtractor.create(httpAttributesExtractor); + NetClientAttributesExtractor netAttributesExtractor = + NetClientAttributesExtractor.create(netAttributesGetter); INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), @@ -30,7 +33,7 @@ public class HttpUrlConnectionSingletons { spanNameExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(RequestPropertySetter.INSTANCE); } diff --git a/instrumentation/http-url-connection/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpurlconnection/HttpUrlNetAttributesExtractor.java b/instrumentation/http-url-connection/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpurlconnection/HttpUrlNetAttributesGetter.java similarity index 87% rename from instrumentation/http-url-connection/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpurlconnection/HttpUrlNetAttributesExtractor.java rename to instrumentation/http-url-connection/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpurlconnection/HttpUrlNetAttributesGetter.java index 618ce73dc154..1c288e627df8 100644 --- a/instrumentation/http-url-connection/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpurlconnection/HttpUrlNetAttributesExtractor.java +++ b/instrumentation/http-url-connection/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpurlconnection/HttpUrlNetAttributesGetter.java @@ -5,13 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.httpurlconnection; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.HttpURLConnection; import javax.annotation.Nullable; -class HttpUrlNetAttributesExtractor - extends NetClientAttributesExtractor { +class HttpUrlNetAttributesGetter implements NetClientAttributesGetter { + @Override @Nullable public String transport(HttpURLConnection connection, @Nullable Integer status) { diff --git a/instrumentation/java-http-client/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpclient/JdkHttpClientSingletons.java b/instrumentation/java-http-client/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpclient/JdkHttpClientSingletons.java index d0b494385859..16537eb40f83 100644 --- a/instrumentation/java-http-client/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpclient/JdkHttpClientSingletons.java +++ b/instrumentation/java-http-client/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpclient/JdkHttpClientSingletons.java @@ -13,6 +13,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import java.net.http.HttpRequest; import java.net.http.HttpResponse; @@ -28,7 +29,9 @@ public class JdkHttpClientSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor> spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - JdkHttpNetAttributesExtractor netAttributesExtractor = new JdkHttpNetAttributesExtractor(); + JdkHttpNetAttributesGetter netAttributesGetter = new JdkHttpNetAttributesGetter(); + NetClientAttributesExtractor> netAttributesExtractor = + NetClientAttributesExtractor.create(netAttributesGetter); INSTRUMENTER = Instrumenter.>builder( @@ -36,7 +39,7 @@ public class JdkHttpClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(SETTER); } diff --git a/instrumentation/java-http-client/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpclient/JdkHttpNetAttributesExtractor.java b/instrumentation/java-http-client/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpclient/JdkHttpNetAttributesGetter.java similarity index 89% rename from instrumentation/java-http-client/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpclient/JdkHttpNetAttributesExtractor.java rename to instrumentation/java-http-client/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpclient/JdkHttpNetAttributesGetter.java index 09fc7b9c89b9..9f2aca2fdb20 100644 --- a/instrumentation/java-http-client/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpclient/JdkHttpNetAttributesExtractor.java +++ b/instrumentation/java-http-client/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpclient/JdkHttpNetAttributesGetter.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.httpclient; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.http.HttpRequest; import java.net.http.HttpResponse; @@ -13,10 +13,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class JdkHttpNetAttributesExtractor - extends NetClientAttributesExtractor> { +public class JdkHttpNetAttributesGetter + implements NetClientAttributesGetter> { - private static final Logger logger = LoggerFactory.getLogger(JdkHttpNetAttributesExtractor.class); + private static final Logger logger = LoggerFactory.getLogger(JdkHttpNetAttributesGetter.class); @Override public String transport(HttpRequest httpRequest, @Nullable HttpResponse response) { diff --git a/instrumentation/jaxrs-client/jaxrs-client-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v1_1/JaxRsClientNetAttributesExtractor.java b/instrumentation/jaxrs-client/jaxrs-client-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v1_1/JaxRsClientNetAttributesGetter.java similarity index 88% rename from instrumentation/jaxrs-client/jaxrs-client-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v1_1/JaxRsClientNetAttributesExtractor.java rename to instrumentation/jaxrs-client/jaxrs-client-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v1_1/JaxRsClientNetAttributesGetter.java index a6ae9f43cb34..63f35227ed60 100644 --- a/instrumentation/jaxrs-client/jaxrs-client-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v1_1/JaxRsClientNetAttributesExtractor.java +++ b/instrumentation/jaxrs-client/jaxrs-client-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v1_1/JaxRsClientNetAttributesGetter.java @@ -7,12 +7,12 @@ import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; -final class JaxRsClientNetAttributesExtractor - extends NetClientAttributesExtractor { +final class JaxRsClientNetAttributesGetter + implements NetClientAttributesGetter { @Override public String transport(ClientRequest request, @Nullable ClientResponse response) { diff --git a/instrumentation/jaxrs-client/jaxrs-client-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v1_1/JaxRsClientSingletons.java b/instrumentation/jaxrs-client/jaxrs-client-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v1_1/JaxRsClientSingletons.java index 642183db5b0d..aa39b1dd1dcd 100644 --- a/instrumentation/jaxrs-client/jaxrs-client-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v1_1/JaxRsClientSingletons.java +++ b/instrumentation/jaxrs-client/jaxrs-client-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v1_1/JaxRsClientSingletons.java @@ -16,6 +16,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; public class JaxRsClientSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jaxrs-client-1.1"; @@ -29,8 +30,9 @@ public class JaxRsClientSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - JaxRsClientNetAttributesExtractor netAttributesExtractor = - new JaxRsClientNetAttributesExtractor(); + JaxRsClientNetAttributesGetter netAttributesGetter = new JaxRsClientNetAttributesGetter(); + NetClientAttributesExtractor netAttributesExtractor = + NetClientAttributesExtractor.create(netAttributesGetter); INSTRUMENTER = Instrumenter.builder( @@ -38,7 +40,7 @@ public class JaxRsClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(ClientRequestHeaderSetter.INSTANCE); } diff --git a/instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/JaxRsClientNetAttributesExtractor.java b/instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/JaxRsClientNetAttributesGetter.java similarity index 89% rename from instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/JaxRsClientNetAttributesExtractor.java rename to instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/JaxRsClientNetAttributesGetter.java index cd0b40fb43a3..8a0f17ba0d08 100644 --- a/instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/JaxRsClientNetAttributesExtractor.java +++ b/instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/JaxRsClientNetAttributesGetter.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.jaxrsclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; import javax.ws.rs.client.ClientRequestContext; import javax.ws.rs.client.ClientResponseContext; -final class JaxRsClientNetAttributesExtractor - extends NetClientAttributesExtractor { +final class JaxRsClientNetAttributesGetter + implements NetClientAttributesGetter { @Override public String transport(ClientRequestContext request, @Nullable ClientResponseContext response) { diff --git a/instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/JaxRsClientSingletons.java b/instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/JaxRsClientSingletons.java index fa42bbf22eda..b897dbe4d1c3 100644 --- a/instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/JaxRsClientSingletons.java +++ b/instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/JaxRsClientSingletons.java @@ -15,6 +15,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import javax.ws.rs.ProcessingException; import javax.ws.rs.client.ClientRequestContext; import javax.ws.rs.client.ClientResponseContext; @@ -31,8 +32,9 @@ public class JaxRsClientSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - JaxRsClientNetAttributesExtractor netAttributesExtractor = - new JaxRsClientNetAttributesExtractor(); + JaxRsClientNetAttributesGetter netAttributesGetter = new JaxRsClientNetAttributesGetter(); + NetClientAttributesExtractor + netClientAttributesExtractor = NetClientAttributesExtractor.create(netAttributesGetter); INSTRUMENTER = Instrumenter.builder( @@ -46,8 +48,8 @@ public class JaxRsClientSingletons { return ErrorCauseExtractor.jdk().extractCause(throwable); }) .addAttributesExtractor(httpAttributesExtractor) - .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(netClientAttributesExtractor) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(ClientRequestContextHeaderSetter.INSTANCE); } diff --git a/instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-resteasy-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/ResteasyClientNetAttributesExtractor.java b/instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-resteasy-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/ResteasyClientNetAttributesGetter.java similarity index 88% rename from instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-resteasy-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/ResteasyClientNetAttributesExtractor.java rename to instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-resteasy-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/ResteasyClientNetAttributesGetter.java index 51aa7dcf6522..44ded0b2df96 100644 --- a/instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-resteasy-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/ResteasyClientNetAttributesExtractor.java +++ b/instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-resteasy-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/ResteasyClientNetAttributesGetter.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.jaxrsclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; import javax.ws.rs.core.Response; import org.jboss.resteasy.client.jaxrs.internal.ClientInvocation; -final class ResteasyClientNetAttributesExtractor - extends NetClientAttributesExtractor { +final class ResteasyClientNetAttributesGetter + implements NetClientAttributesGetter { @Override public String transport(ClientInvocation request, @Nullable Response response) { diff --git a/instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-resteasy-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/ResteasyClientSingletons.java b/instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-resteasy-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/ResteasyClientSingletons.java index 755160547b59..4476c077f4c0 100644 --- a/instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-resteasy-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/ResteasyClientSingletons.java +++ b/instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-resteasy-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/ResteasyClientSingletons.java @@ -15,6 +15,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import javax.ws.rs.ProcessingException; import javax.ws.rs.core.Response; import org.jboss.resteasy.client.jaxrs.internal.ClientInvocation; @@ -32,8 +33,9 @@ public class ResteasyClientSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - ResteasyClientNetAttributesExtractor netAttributesExtractor = - new ResteasyClientNetAttributesExtractor(); + ResteasyClientNetAttributesGetter netAttributesGetter = new ResteasyClientNetAttributesGetter(); + NetClientAttributesExtractor netAttributesExtractor = + NetClientAttributesExtractor.create(netAttributesGetter); INSTRUMENTER = Instrumenter.builder( @@ -48,7 +50,7 @@ public class ResteasyClientSingletons { }) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(ClientInvocationHeaderSetter.INSTANCE); } diff --git a/instrumentation/jdbc/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jdbc/JdbcSingletons.java b/instrumentation/jdbc/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jdbc/JdbcSingletons.java index 2d4df74fc266..80a9bf624d3a 100644 --- a/instrumentation/jdbc/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jdbc/JdbcSingletons.java +++ b/instrumentation/jdbc/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jdbc/JdbcSingletons.java @@ -12,9 +12,10 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbSpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.instrumentation.jdbc.internal.DbRequest; import io.opentelemetry.instrumentation.jdbc.internal.JdbcAttributesExtractor; -import io.opentelemetry.instrumentation.jdbc.internal.JdbcNetAttributesExtractor; +import io.opentelemetry.instrumentation.jdbc.internal.JdbcNetAttributesGetter; public final class JdbcSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jdbc"; @@ -24,14 +25,15 @@ public final class JdbcSingletons { static { DbAttributesExtractor dbAttributesExtractor = new JdbcAttributesExtractor(); SpanNameExtractor spanName = DbSpanNameExtractor.create(dbAttributesExtractor); - JdbcNetAttributesExtractor netAttributesExtractor = new JdbcNetAttributesExtractor(); - + JdbcNetAttributesGetter netAttributesGetter = new JdbcNetAttributesGetter(); + NetClientAttributesExtractor netAttributesExtractor = + NetClientAttributesExtractor.create(netAttributesGetter); INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanName) .addAttributesExtractor(dbAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter)) .newInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcNetAttributesExtractor.java b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcNetAttributesGetter.java similarity index 85% rename from instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcNetAttributesExtractor.java rename to instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcNetAttributesGetter.java index 28d615befe6c..b098f646155a 100644 --- a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcNetAttributesExtractor.java +++ b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcNetAttributesGetter.java @@ -5,11 +5,10 @@ package io.opentelemetry.instrumentation.jdbc.internal; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import javax.annotation.Nullable; -public final class JdbcNetAttributesExtractor - extends NetClientAttributesExtractor { +public final class JdbcNetAttributesGetter implements NetClientAttributesGetter { @Nullable @Override diff --git a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcSingletons.java b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcSingletons.java index 1fa8c2f87216..4f6505aec671 100644 --- a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcSingletons.java +++ b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcSingletons.java @@ -11,6 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbSpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; public final class JdbcSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jdbc"; @@ -20,7 +21,8 @@ public final class JdbcSingletons { static { DbAttributesExtractor dbAttributesExtractor = new JdbcAttributesExtractor(); SpanNameExtractor spanName = DbSpanNameExtractor.create(dbAttributesExtractor); - JdbcNetAttributesExtractor netAttributesExtractor = new JdbcNetAttributesExtractor(); + NetClientAttributesExtractor netAttributesExtractor = + NetClientAttributesExtractor.create(new JdbcNetAttributesGetter()); INSTRUMENTER = Instrumenter.builder( diff --git a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisNetAttributesExtractor.java b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisNetAttributesGetter.java similarity index 85% rename from instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisNetAttributesExtractor.java rename to instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisNetAttributesGetter.java index dd482528f2c6..0e0338016f7e 100644 --- a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisNetAttributesExtractor.java +++ b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisNetAttributesGetter.java @@ -5,10 +5,10 @@ package io.opentelemetry.javaagent.instrumentation.jedis.v1_4; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import javax.annotation.Nullable; -final class JedisNetAttributesExtractor extends NetClientAttributesExtractor { +final class JedisNetAttributesGetter implements NetClientAttributesGetter { @Override @Nullable diff --git a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisSingletons.java b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisSingletons.java index a4e0e0cb713a..e377bc74d223 100644 --- a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisSingletons.java +++ b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisSingletons.java @@ -12,6 +12,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbSpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; public final class JedisSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jedis-1.4"; @@ -22,14 +23,16 @@ public final class JedisSingletons { DbAttributesExtractor attributesExtractor = new JedisDbAttributesExtractor(); SpanNameExtractor spanName = DbSpanNameExtractor.create(attributesExtractor); - JedisNetAttributesExtractor netAttributesExtractor = new JedisNetAttributesExtractor(); + JedisNetAttributesGetter netAttributesGetter = new JedisNetAttributesGetter(); + NetClientAttributesExtractor netAttributesExtractor = + NetClientAttributesExtractor.create(netAttributesGetter); INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanName) .addAttributesExtractor(attributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter)) .newInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisNetAttributesExtractor.java b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisNetAttributesGetter.java similarity index 84% rename from instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisNetAttributesExtractor.java rename to instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisNetAttributesGetter.java index 36fa796912f8..395626a1d6ba 100644 --- a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisNetAttributesExtractor.java +++ b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisNetAttributesGetter.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.jedis.v3_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import java.net.Socket; import javax.annotation.Nullable; -final class JedisNetAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { +final class JedisNetAttributesGetter + extends InetSocketAddressNetClientAttributesGetter { @Override @Nullable diff --git a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisSingletons.java b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisSingletons.java index 8d1d6dcaf4f3..2fef65523ba4 100644 --- a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisSingletons.java +++ b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisSingletons.java @@ -12,6 +12,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbSpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; public final class JedisSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jedis-3.0"; @@ -22,14 +23,16 @@ public final class JedisSingletons { DbAttributesExtractor attributesExtractor = new JedisDbAttributesExtractor(); SpanNameExtractor spanName = DbSpanNameExtractor.create(attributesExtractor); - JedisNetAttributesExtractor netAttributesExtractor = new JedisNetAttributesExtractor(); + JedisNetAttributesGetter netAttributesGetter = new JedisNetAttributesGetter(); + NetClientAttributesExtractor netAttributesExtractor = + NetClientAttributesExtractor.create(netAttributesGetter); INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanName) .addAttributesExtractor(attributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter)) .newInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisNetAttributesExtractor.java b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisNetAttributesGetter.java similarity index 84% rename from instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisNetAttributesExtractor.java rename to instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisNetAttributesGetter.java index 816152bac1b2..873daf066ec0 100644 --- a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisNetAttributesExtractor.java +++ b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisNetAttributesGetter.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.jedis.v4_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import java.net.SocketAddress; import javax.annotation.Nullable; -final class JedisNetAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { +final class JedisNetAttributesGetter + extends InetSocketAddressNetClientAttributesGetter { @Override @Nullable diff --git a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisSingletons.java b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisSingletons.java index 1d97a8165f88..10e984f45967 100644 --- a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisSingletons.java +++ b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisSingletons.java @@ -12,6 +12,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbSpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; public final class JedisSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jedis-3.0"; @@ -22,14 +23,14 @@ public final class JedisSingletons { DbAttributesExtractor attributesExtractor = new JedisDbAttributesExtractor(); SpanNameExtractor spanName = DbSpanNameExtractor.create(attributesExtractor); - JedisNetAttributesExtractor netAttributesExtractor = new JedisNetAttributesExtractor(); + JedisNetAttributesGetter netAttributesGetter = new JedisNetAttributesGetter(); INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanName) .addAttributesExtractor(attributesExtractor) - .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(NetClientAttributesExtractor.create(netAttributesGetter)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter)) .newInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jetty/httpclient/v9_2/JettyHttpClientSingletons.java b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jetty/httpclient/v9_2/JettyHttpClientSingletons.java index 816f2b132556..7c3db813cef6 100644 --- a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jetty/httpclient/v9_2/JettyHttpClientSingletons.java +++ b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jetty/httpclient/v9_2/JettyHttpClientSingletons.java @@ -9,7 +9,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal.JettyClientInstrumenterBuilder; -import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal.JettyHttpClientNetAttributesExtractor; +import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal.JettyHttpClientNetAttributesGetter; import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.api.Response; @@ -24,7 +24,7 @@ private JettyHttpClientSingletons() {} new JettyClientInstrumenterBuilder(GlobalOpenTelemetry.get()); PeerServiceAttributesExtractor peerServiceAttributesExtractor = - PeerServiceAttributesExtractor.create(new JettyHttpClientNetAttributesExtractor()); + PeerServiceAttributesExtractor.create(new JettyHttpClientNetAttributesGetter()); INSTRUMENTER = builder.addAttributeExtractor(peerServiceAttributesExtractor).build(); } diff --git a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/JettyClientInstrumenterBuilder.java b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/JettyClientInstrumenterBuilder.java index aad9e6a80555..53cd7ab07dc7 100644 --- a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/JettyClientInstrumenterBuilder.java +++ b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/JettyClientInstrumenterBuilder.java @@ -16,6 +16,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import java.util.ArrayList; import java.util.List; import org.eclipse.jetty.client.api.Request; @@ -54,14 +55,16 @@ public Instrumenter build() { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - JettyHttpClientNetAttributesExtractor netAttributesExtractor = - new JettyHttpClientNetAttributesExtractor(); + JettyHttpClientNetAttributesGetter netAttributesGetter = + new JettyHttpClientNetAttributesGetter(); + NetClientAttributesExtractor attributesExtractor = + NetClientAttributesExtractor.create(netAttributesGetter); return Instrumenter.builder( this.openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor) .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) - .addAttributesExtractor(netAttributesExtractor) + .addAttributesExtractor(attributesExtractor) .addAttributesExtractors(additionalExtractors) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(HttpHeaderSetter.INSTANCE); diff --git a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/JettyHttpClientNetAttributesExtractor.java b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/JettyHttpClientNetAttributesGetter.java similarity index 89% rename from instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/JettyHttpClientNetAttributesExtractor.java rename to instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/JettyHttpClientNetAttributesGetter.java index 161c4ae5309d..81597faaa8df 100644 --- a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/JettyHttpClientNetAttributesExtractor.java +++ b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/JettyHttpClientNetAttributesGetter.java @@ -5,14 +5,14 @@ package io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.api.Response; -public class JettyHttpClientNetAttributesExtractor - extends NetClientAttributesExtractor { +public class JettyHttpClientNetAttributesGetter + implements NetClientAttributesGetter { @Override public String transport(Request request, @Nullable Response response) { diff --git a/instrumentation/kubernetes-client-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kubernetesclient/KubernetesClientSingletons.java b/instrumentation/kubernetes-client-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kubernetesclient/KubernetesClientSingletons.java index 83053e30af01..30f7382e8cee 100644 --- a/instrumentation/kubernetes-client-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kubernetesclient/KubernetesClientSingletons.java +++ b/instrumentation/kubernetes-client-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kubernetesclient/KubernetesClientSingletons.java @@ -16,6 +16,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import okhttp3.Request; public class KubernetesClientSingletons { @@ -39,7 +40,8 @@ public class KubernetesClientSingletons { spanNameExtractor) .setSpanStatusExtractor(HttpSpanStatusExtractor.create(httpAttributesExtractor)) .addAttributesExtractor(httpAttributesExtractor) - .addAttributesExtractor(new KubernetesNetAttributesExtractor()); + .addAttributesExtractor( + NetClientAttributesExtractor.create(new KubernetesNetAttributesGetter())); if (CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES) { instrumenterBuilder.addAttributesExtractor(new KubernetesExperimentalAttributesExtractor()); diff --git a/instrumentation/kubernetes-client-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kubernetesclient/KubernetesNetAttributesExtractor.java b/instrumentation/kubernetes-client-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kubernetesclient/KubernetesNetAttributesGetter.java similarity index 87% rename from instrumentation/kubernetes-client-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kubernetesclient/KubernetesNetAttributesExtractor.java rename to instrumentation/kubernetes-client-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kubernetesclient/KubernetesNetAttributesGetter.java index ef4ae81d5a6e..701a5dd4fcf3 100644 --- a/instrumentation/kubernetes-client-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kubernetesclient/KubernetesNetAttributesExtractor.java +++ b/instrumentation/kubernetes-client-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kubernetesclient/KubernetesNetAttributesGetter.java @@ -6,13 +6,13 @@ package io.opentelemetry.javaagent.instrumentation.kubernetesclient; import io.kubernetes.client.openapi.ApiResponse; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; import okhttp3.Request; -class KubernetesNetAttributesExtractor - extends NetClientAttributesExtractor> { +class KubernetesNetAttributesGetter implements NetClientAttributesGetter> { + @Override public String transport(Request request, @Nullable ApiResponse response) { return SemanticAttributes.NetTransportValues.IP_TCP; diff --git a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceConnectNetAttributesExtractor.java b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceConnectNetAttributesGetter.java similarity index 84% rename from instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceConnectNetAttributesExtractor.java rename to instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceConnectNetAttributesGetter.java index 3cbac2686993..6eff970d3cbc 100644 --- a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceConnectNetAttributesExtractor.java +++ b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceConnectNetAttributesGetter.java @@ -6,11 +6,10 @@ package io.opentelemetry.javaagent.instrumentation.lettuce.v4_0; import com.lambdaworks.redis.RedisURI; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import javax.annotation.Nullable; -final class LettuceConnectNetAttributesExtractor - extends NetClientAttributesExtractor { +final class LettuceConnectNetAttributesGetter implements NetClientAttributesGetter { @Override @Nullable diff --git a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceSingletons.java b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceSingletons.java index 4c28b5f1c2c0..92502571c8cf 100644 --- a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceSingletons.java +++ b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceSingletons.java @@ -16,6 +16,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbSpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; public final class LettuceSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.lettuce-4.0"; @@ -38,14 +39,14 @@ public final class LettuceSingletons { .addAttributesExtractor(attributesExtractor) .newInstrumenter(SpanKindExtractor.alwaysClient()); - LettuceConnectNetAttributesExtractor connectNetAttributesExtractor = - new LettuceConnectNetAttributesExtractor(); + LettuceConnectNetAttributesGetter netAttributesGetter = new LettuceConnectNetAttributesGetter(); + NetClientAttributesExtractor netClientAttributesExtractor = + NetClientAttributesExtractor.create(netAttributesGetter); CONNECT_INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, redisUri -> "CONNECT") - .addAttributesExtractor(connectNetAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesExtractor.create(connectNetAttributesExtractor)) + .addAttributesExtractor(netClientAttributesExtractor) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter)) .addAttributesExtractor(new LettuceConnectAttributesExtractor()) .newInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceConnectNetAttributesExtractor.java b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceConnectNetAttributesGetter.java similarity index 84% rename from instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceConnectNetAttributesExtractor.java rename to instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceConnectNetAttributesGetter.java index ae0f5552e2fa..9a84b513e006 100644 --- a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceConnectNetAttributesExtractor.java +++ b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceConnectNetAttributesGetter.java @@ -6,11 +6,10 @@ package io.opentelemetry.javaagent.instrumentation.lettuce.v5_0; import io.lettuce.core.RedisURI; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import javax.annotation.Nullable; -final class LettuceConnectNetAttributesExtractor - extends NetClientAttributesExtractor { +final class LettuceConnectNetAttributesGetter implements NetClientAttributesGetter { @Override @Nullable diff --git a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceSingletons.java b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceSingletons.java index c479c149583e..5421fd542889 100644 --- a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceSingletons.java +++ b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceSingletons.java @@ -16,6 +16,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbSpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; public final class LettuceSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.lettuce-5.0"; @@ -38,14 +39,16 @@ public final class LettuceSingletons { .addAttributesExtractor(attributesExtractor) .newInstrumenter(SpanKindExtractor.alwaysClient()); - LettuceConnectNetAttributesExtractor connectNetAttributesExtractor = - new LettuceConnectNetAttributesExtractor(); + LettuceConnectNetAttributesGetter connectNetAttributesGetter = + new LettuceConnectNetAttributesGetter(); + NetClientAttributesExtractor netAttributesExtractor = + NetClientAttributesExtractor.create(connectNetAttributesGetter); CONNECT_INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, redisUri -> "CONNECT") - .addAttributesExtractor(connectNetAttributesExtractor) + .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesExtractor.create(connectNetAttributesExtractor)) + PeerServiceAttributesExtractor.create(connectNetAttributesGetter)) .addAttributesExtractor(new LettuceConnectAttributesExtractor()) .newInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceNetAttributesExtractor.java b/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceNetAttributesGetter.java similarity index 87% rename from instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceNetAttributesExtractor.java rename to instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceNetAttributesGetter.java index cb774eae105f..9e1cd5f15c3e 100644 --- a/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceNetAttributesExtractor.java +++ b/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceNetAttributesGetter.java @@ -7,12 +7,12 @@ import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_TCP; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.instrumentation.lettuce.v5_1.OpenTelemetryTracing.OpenTelemetryEndpoint; import javax.annotation.Nullable; -final class LettuceNetAttributesExtractor - extends NetClientAttributesExtractor { +final class LettuceNetAttributesGetter + implements NetClientAttributesGetter { @Override public String transport(OpenTelemetryEndpoint endpoint, @Nullable Void unused) { diff --git a/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/OpenTelemetryTracing.java b/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/OpenTelemetryTracing.java index 9ce7d7d30893..2a010614bd34 100644 --- a/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/OpenTelemetryTracing.java +++ b/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/OpenTelemetryTracing.java @@ -23,6 +23,7 @@ import io.opentelemetry.api.trace.StatusCode; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.db.RedisCommandSanitizer; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes.DbSystemValues; import java.net.InetSocketAddress; @@ -34,8 +35,9 @@ final class OpenTelemetryTracing implements Tracing { - private static final LettuceNetAttributesExtractor netAttributesExtractor = - new LettuceNetAttributesExtractor(); + private static final NetClientAttributesExtractor + netAttributesExtractor = + NetClientAttributesExtractor.create(new LettuceNetAttributesGetter()); private final TracerProvider tracerProvider; OpenTelemetryTracing(io.opentelemetry.api.trace.Tracer tracer) { diff --git a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoInstrumenterFactory.java b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoInstrumenterFactory.java index 8627a8a498db..a6177e30fd8c 100644 --- a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoInstrumenterFactory.java +++ b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoInstrumenterFactory.java @@ -10,13 +10,14 @@ import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; class MongoInstrumenterFactory { private static final MongoAttributesExtractor attributesExtractor = new MongoAttributesExtractor(); - private static final MongoNetAttributesExtractor netAttributesExtractor = - new MongoNetAttributesExtractor(); + private static final NetClientAttributesExtractor + netAttributesExtractor = NetClientAttributesExtractor.create(new MongoNetAttributesGetter()); static Instrumenter createInstrumenter( OpenTelemetry openTelemetry, int maxNormalizedQueryLength) { diff --git a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoNetAttributesExtractor.java b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoNetAttributesGetter.java similarity index 83% rename from instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoNetAttributesExtractor.java rename to instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoNetAttributesGetter.java index e8162222e299..787ec3272cc1 100644 --- a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoNetAttributesExtractor.java +++ b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoNetAttributesGetter.java @@ -6,12 +6,12 @@ package io.opentelemetry.instrumentation.mongo.v3_1; import com.mongodb.event.CommandStartedEvent; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter; import java.net.InetSocketAddress; import javax.annotation.Nullable; -class MongoNetAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { +class MongoNetAttributesGetter + extends InetSocketAddressNetClientAttributesGetter { @Override @Nullable public InetSocketAddress getAddress(CommandStartedEvent event, @Nullable Void unused) { diff --git a/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/client/NettyClientSingletons.java b/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/client/NettyClientSingletons.java index 9497a79aafc9..17298ccf714b 100644 --- a/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/client/NettyClientSingletons.java +++ b/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/client/NettyClientSingletons.java @@ -12,6 +12,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.javaagent.instrumentation.netty.common.NettyConnectionRequest; import io.opentelemetry.javaagent.instrumentation.netty.common.NettyErrorHolder; import io.opentelemetry.javaagent.instrumentation.netty.v3_8.HttpRequestAndChannel; @@ -28,8 +29,9 @@ public final class NettyClientSingletons { static { NettyHttpClientAttributesExtractor httpClientAttributesExtractor = new NettyHttpClientAttributesExtractor(); - NettyNetClientAttributesExtractor netClientAttributesExtractor = - new NettyNetClientAttributesExtractor(); + NettyNetClientAttributesGetter netClientAttributesGetter = new NettyNetClientAttributesGetter(); + NetClientAttributesExtractor netClientAttributesExtractor = + NetClientAttributesExtractor.create(netClientAttributesGetter); INSTRUMENTER = Instrumenter.builder( @@ -40,20 +42,22 @@ public final class NettyClientSingletons { .addAttributesExtractor(httpClientAttributesExtractor) .addAttributesExtractor(netClientAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesExtractor.create(netClientAttributesExtractor)) + PeerServiceAttributesExtractor.create(netClientAttributesGetter)) .addRequestMetrics(HttpClientMetrics.get()) .addContextCustomizer( (context, requestAndChannel, startAttributes) -> NettyErrorHolder.init(context)) .newClientInstrumenter(HttpRequestHeadersSetter.INSTANCE); - NettyConnectNetAttributesExtractor nettyConnectAttributesExtractor = - new NettyConnectNetAttributesExtractor(); + NettyConnectNetAttributesGetter nettyConnectAttributesGetter = + new NettyConnectNetAttributesGetter(); + NetClientAttributesExtractor nettyConnectAttributesExtractor = + NetClientAttributesExtractor.create(nettyConnectAttributesGetter); CONNECTION_INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, NettyConnectionRequest::spanName) .addAttributesExtractor(nettyConnectAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesExtractor.create(nettyConnectAttributesExtractor)) + PeerServiceAttributesExtractor.create(nettyConnectAttributesGetter)) .setTimeExtractor(new NettyConnectionTimeExtractor()) .newInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/client/NettyConnectNetAttributesExtractor.java b/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/client/NettyConnectNetAttributesGetter.java similarity index 88% rename from instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/client/NettyConnectNetAttributesExtractor.java rename to instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/client/NettyConnectNetAttributesGetter.java index 7def69496a69..e15feaa5c129 100644 --- a/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/client/NettyConnectNetAttributesExtractor.java +++ b/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/client/NettyConnectNetAttributesGetter.java @@ -8,7 +8,7 @@ import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_TCP; import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_UDP; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter; import io.opentelemetry.javaagent.instrumentation.netty.common.NettyConnectionRequest; import java.net.InetSocketAddress; import java.net.SocketAddress; @@ -16,8 +16,8 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.socket.DatagramChannel; -final class NettyConnectNetAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { +final class NettyConnectNetAttributesGetter + extends InetSocketAddressNetClientAttributesGetter { @Nullable @Override diff --git a/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/client/NettyNetClientAttributesExtractor.java b/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/client/NettyNetClientAttributesGetter.java similarity index 83% rename from instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/client/NettyNetClientAttributesExtractor.java rename to instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/client/NettyNetClientAttributesGetter.java index d141384572e4..8364398b0618 100644 --- a/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/client/NettyNetClientAttributesExtractor.java +++ b/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/client/NettyNetClientAttributesGetter.java @@ -5,15 +5,15 @@ package io.opentelemetry.javaagent.instrumentation.netty.v3_8.client; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter; import io.opentelemetry.javaagent.instrumentation.netty.v3_8.HttpRequestAndChannel; import java.net.InetSocketAddress; import java.net.SocketAddress; import javax.annotation.Nullable; import org.jboss.netty.handler.codec.http.HttpResponse; -final class NettyNetClientAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { +final class NettyNetClientAttributesGetter + extends InetSocketAddressNetClientAttributesGetter { @Override @Nullable diff --git a/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettyClientInstrumenterFactory.java b/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettyClientInstrumenterFactory.java index 31d3be3cbd32..9e74cb61dd4e 100644 --- a/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettyClientInstrumenterFactory.java +++ b/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettyClientInstrumenterFactory.java @@ -14,6 +14,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.javaagent.instrumentation.netty.common.HttpRequestAndChannel; import io.opentelemetry.javaagent.instrumentation.netty.common.NettyConnectionRequest; @@ -33,8 +34,8 @@ public NettyClientInstrumenterFactory( public Instrumenter createHttpInstrumenter() { NettyHttpClientAttributesExtractor httpClientAttributesExtractor = new NettyHttpClientAttributesExtractor(); - NettyNetClientAttributesExtractor netClientAttributesExtractor = - new NettyNetClientAttributesExtractor(); + NettyNetClientAttributesGetter netClientAttributesExtractor = + new NettyNetClientAttributesGetter(); return Instrumenter.builder( GlobalOpenTelemetry.get(), @@ -42,19 +43,18 @@ public Instrumenter createHttpInstrumenter( HttpSpanNameExtractor.create(httpClientAttributesExtractor)) .setSpanStatusExtractor(HttpSpanStatusExtractor.create(httpClientAttributesExtractor)) .addAttributesExtractor(httpClientAttributesExtractor) - .addAttributesExtractor(netClientAttributesExtractor) + .addAttributesExtractor(NetClientAttributesExtractor.create(netClientAttributesExtractor)) .addAttributesExtractor(PeerServiceAttributesExtractor.create(netClientAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(HttpRequestHeadersSetter.INSTANCE); } public NettyConnectionInstrumenter createConnectionInstrumenter() { - NettyConnectNetAttributesExtractor netAttributesExtractor = - new NettyConnectNetAttributesExtractor(); + NettyConnectNetAttributesGetter netAttributesExtractor = new NettyConnectNetAttributesGetter(); Instrumenter instrumenter = Instrumenter.builder( GlobalOpenTelemetry.get(), instrumentationName, NettyConnectionRequest::spanName) - .addAttributesExtractor(netAttributesExtractor) + .addAttributesExtractor(NetClientAttributesExtractor.create(netAttributesExtractor)) .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .setTimeExtractor(new NettyConnectionTimeExtractor()) .newInstrumenter( @@ -68,11 +68,11 @@ public NettyConnectionInstrumenter createConnectionInstrumenter() { } public NettySslInstrumenter createSslInstrumenter() { - NettySslNetAttributesExtractor netAttributesExtractor = new NettySslNetAttributesExtractor(); + NettySslNetAttributesGetter netAttributesExtractor = new NettySslNetAttributesGetter(); Instrumenter instrumenter = Instrumenter.builder( GlobalOpenTelemetry.get(), instrumentationName, NettySslRequest::spanName) - .addAttributesExtractor(netAttributesExtractor) + .addAttributesExtractor(NetClientAttributesExtractor.create(netAttributesExtractor)) .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .setTimeExtractor(new NettySslTimeExtractor()) .newInstrumenter( diff --git a/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettyConnectNetAttributesExtractor.java b/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettyConnectNetAttributesGetter.java similarity index 88% rename from instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettyConnectNetAttributesExtractor.java rename to instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettyConnectNetAttributesGetter.java index d4754eed18d6..a65ccebff59b 100644 --- a/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettyConnectNetAttributesExtractor.java +++ b/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettyConnectNetAttributesGetter.java @@ -10,14 +10,14 @@ import io.netty.channel.Channel; import io.netty.channel.socket.DatagramChannel; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter; import io.opentelemetry.javaagent.instrumentation.netty.common.NettyConnectionRequest; import java.net.InetSocketAddress; import java.net.SocketAddress; import javax.annotation.Nullable; -final class NettyConnectNetAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { +final class NettyConnectNetAttributesGetter + extends InetSocketAddressNetClientAttributesGetter { @Nullable @Override diff --git a/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettyNetClientAttributesExtractor.java b/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettyNetClientAttributesGetter.java similarity index 83% rename from instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettyNetClientAttributesExtractor.java rename to instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettyNetClientAttributesGetter.java index 213d8a2b6e0d..fd1cb448ce61 100644 --- a/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettyNetClientAttributesExtractor.java +++ b/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettyNetClientAttributesGetter.java @@ -6,14 +6,14 @@ package io.opentelemetry.javaagent.instrumentation.netty.common.client; import io.netty.handler.codec.http.HttpResponse; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter; import io.opentelemetry.javaagent.instrumentation.netty.common.HttpRequestAndChannel; import java.net.InetSocketAddress; import java.net.SocketAddress; import javax.annotation.Nullable; -final class NettyNetClientAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { +final class NettyNetClientAttributesGetter + extends InetSocketAddressNetClientAttributesGetter { @Override @Nullable diff --git a/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettySslNetAttributesExtractor.java b/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettySslNetAttributesGetter.java similarity index 85% rename from instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettySslNetAttributesExtractor.java rename to instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettySslNetAttributesGetter.java index 676226cea28f..68ece2faf15d 100644 --- a/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettySslNetAttributesExtractor.java +++ b/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/client/NettySslNetAttributesGetter.java @@ -9,12 +9,12 @@ import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_UDP; import io.netty.channel.socket.DatagramChannel; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter; import java.net.InetSocketAddress; import javax.annotation.Nullable; -final class NettySslNetAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { +final class NettySslNetAttributesGetter + extends InetSocketAddressNetClientAttributesGetter { @Nullable @Override diff --git a/instrumentation/okhttp/okhttp-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/okhttp/v2_2/OkHttp2NetAttributesExtractor.java b/instrumentation/okhttp/okhttp-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/okhttp/v2_2/OkHttp2NetAttributesGetter.java similarity index 86% rename from instrumentation/okhttp/okhttp-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/okhttp/v2_2/OkHttp2NetAttributesExtractor.java rename to instrumentation/okhttp/okhttp-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/okhttp/v2_2/OkHttp2NetAttributesGetter.java index 058fc5a6e569..ce2dd1e51522 100644 --- a/instrumentation/okhttp/okhttp-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/okhttp/v2_2/OkHttp2NetAttributesExtractor.java +++ b/instrumentation/okhttp/okhttp-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/okhttp/v2_2/OkHttp2NetAttributesGetter.java @@ -7,12 +7,13 @@ import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; -public final class OkHttp2NetAttributesExtractor - extends NetClientAttributesExtractor { +public final class OkHttp2NetAttributesGetter + implements NetClientAttributesGetter { + @Override public String transport(Request request, @Nullable Response response) { return SemanticAttributes.NetTransportValues.IP_TCP; diff --git a/instrumentation/okhttp/okhttp-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/okhttp/v2_2/OkHttp2Singletons.java b/instrumentation/okhttp/okhttp-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/okhttp/v2_2/OkHttp2Singletons.java index b2cb41a43e71..75723734c535 100644 --- a/instrumentation/okhttp/okhttp-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/okhttp/v2_2/OkHttp2Singletons.java +++ b/instrumentation/okhttp/okhttp-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/okhttp/v2_2/OkHttp2Singletons.java @@ -35,8 +35,9 @@ public final class OkHttp2Singletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); + OkHttp2NetAttributesGetter netClientAttributesGetter = new OkHttp2NetAttributesGetter(); NetClientAttributesExtractor netAttributesExtractor = - new OkHttp2NetAttributesExtractor(); + NetClientAttributesExtractor.create(netClientAttributesGetter); OpenTelemetry openTelemetry = GlobalOpenTelemetry.get(); @@ -46,7 +47,8 @@ public final class OkHttp2Singletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesExtractor.create(netClientAttributesGetter)) .addRequestMetrics(HttpClientMetrics.get()) .newInstrumenter(alwaysClient()); diff --git a/instrumentation/okhttp/okhttp-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/okhttp/v3_0/OkHttp3Singletons.java b/instrumentation/okhttp/okhttp-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/okhttp/v3_0/OkHttp3Singletons.java index 72ee76be689d..4636fb4cc8b4 100644 --- a/instrumentation/okhttp/okhttp-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/okhttp/v3_0/OkHttp3Singletons.java +++ b/instrumentation/okhttp/okhttp-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/okhttp/v3_0/OkHttp3Singletons.java @@ -8,7 +8,7 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import io.opentelemetry.instrumentation.okhttp.v3_0.OkHttpTracing; -import io.opentelemetry.instrumentation.okhttp.v3_0.internal.OkHttpNetAttributesExtractor; +import io.opentelemetry.instrumentation.okhttp.v3_0.internal.OkHttpNetAttributesGetter; import okhttp3.Interceptor; /** Holder of singleton interceptors for adding to instrumented clients. */ @@ -18,7 +18,7 @@ public final class OkHttp3Singletons { public static final Interceptor TRACING_INTERCEPTOR = OkHttpTracing.builder(GlobalOpenTelemetry.get()) .addAttributesExtractor( - PeerServiceAttributesExtractor.create(new OkHttpNetAttributesExtractor())) + PeerServiceAttributesExtractor.create(new OkHttpNetAttributesGetter())) .build() .newInterceptor(); diff --git a/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/OkHttpTracingBuilder.java b/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/OkHttpTracingBuilder.java index 85bff14631a6..149b1b7afd6b 100644 --- a/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/OkHttpTracingBuilder.java +++ b/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/OkHttpTracingBuilder.java @@ -15,7 +15,8 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; -import io.opentelemetry.instrumentation.okhttp.v3_0.internal.OkHttpNetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.okhttp.v3_0.internal.OkHttpNetAttributesGetter; import java.util.ArrayList; import java.util.List; import okhttp3.Request; @@ -60,7 +61,9 @@ public OkHttpTracingBuilder captureHttpHeaders(CapturedHttpHeaders capturedHttpH public OkHttpTracing build() { OkHttpAttributesExtractor httpAttributesExtractor = new OkHttpAttributesExtractor(capturedHttpHeaders); - OkHttpNetAttributesExtractor netAttributesExtractor = new OkHttpNetAttributesExtractor(); + OkHttpNetAttributesGetter attributesGetter = new OkHttpNetAttributesGetter(); + NetClientAttributesExtractor attributesExtractor = + NetClientAttributesExtractor.create(attributesGetter); Instrumenter instrumenter = Instrumenter.builder( @@ -69,7 +72,7 @@ public OkHttpTracing build() { HttpSpanNameExtractor.create(httpAttributesExtractor)) .setSpanStatusExtractor(HttpSpanStatusExtractor.create(httpAttributesExtractor)) .addAttributesExtractor(httpAttributesExtractor) - .addAttributesExtractor(netAttributesExtractor) + .addAttributesExtractor(attributesExtractor) .addAttributesExtractors(additionalExtractors) .addRequestMetrics(HttpClientMetrics.get()) .newInstrumenter(alwaysClient()); diff --git a/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/internal/OkHttpNetAttributesExtractor.java b/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/internal/OkHttpNetAttributesGetter.java similarity index 86% rename from instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/internal/OkHttpNetAttributesExtractor.java rename to instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/internal/OkHttpNetAttributesGetter.java index 7740f7592e90..04dfdd4bc4f2 100644 --- a/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/internal/OkHttpNetAttributesExtractor.java +++ b/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/internal/OkHttpNetAttributesGetter.java @@ -5,14 +5,15 @@ package io.opentelemetry.instrumentation.okhttp.v3_0.internal; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; import okhttp3.Request; import okhttp3.Response; -public final class OkHttpNetAttributesExtractor - extends NetClientAttributesExtractor { +public final class OkHttpNetAttributesGetter + implements NetClientAttributesGetter { + @Override public String transport(Request request, @Nullable Response response) { return SemanticAttributes.NetTransportValues.IP_TCP; diff --git a/instrumentation/play-ws/play-ws-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/playws/PlayWsClientNetAttributesExtractor.java b/instrumentation/play-ws/play-ws-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/playws/PlayWsClientNetAttributesGetter.java similarity index 83% rename from instrumentation/play-ws/play-ws-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/playws/PlayWsClientNetAttributesExtractor.java rename to instrumentation/play-ws/play-ws-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/playws/PlayWsClientNetAttributesGetter.java index 78f4d757fdd2..96df0b34088f 100644 --- a/instrumentation/play-ws/play-ws-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/playws/PlayWsClientNetAttributesExtractor.java +++ b/instrumentation/play-ws/play-ws-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/playws/PlayWsClientNetAttributesGetter.java @@ -5,15 +5,15 @@ package io.opentelemetry.javaagent.instrumentation.playws; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import javax.annotation.Nullable; import play.shaded.ahc.org.asynchttpclient.Request; import play.shaded.ahc.org.asynchttpclient.Response; -final class PlayWsClientNetAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { +final class PlayWsClientNetAttributesGetter + extends InetSocketAddressNetClientAttributesGetter { @Override public String transport(Request request, @Nullable Response response) { diff --git a/instrumentation/play-ws/play-ws-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/playws/PlayWsClientSingletons.java b/instrumentation/play-ws/play-ws-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/playws/PlayWsClientSingletons.java index 297d50361da8..33d5c03f1fd6 100644 --- a/instrumentation/play-ws/play-ws-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/playws/PlayWsClientSingletons.java +++ b/instrumentation/play-ws/play-ws-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/playws/PlayWsClientSingletons.java @@ -14,6 +14,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import play.shaded.ahc.org.asynchttpclient.Request; import play.shaded.ahc.org.asynchttpclient.Response; @@ -29,16 +30,15 @@ public class PlayWsClientSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - PlayWsClientNetAttributesExtractor netAttributesExtractor = - new PlayWsClientNetAttributesExtractor(); + PlayWsClientNetAttributesGetter netAttributesGetter = new PlayWsClientNetAttributesGetter(); INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanNameExtractor) .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) - .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(NetClientAttributesExtractor.create(netAttributesGetter)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(HttpHeaderSetter.INSTANCE); } diff --git a/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitChannelNetAttributesExtractor.java b/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitChannelNetAttributesGetter.java similarity index 87% rename from instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitChannelNetAttributesExtractor.java rename to instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitChannelNetAttributesGetter.java index 7ecc88a10f13..1fd5da7796b6 100644 --- a/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitChannelNetAttributesExtractor.java +++ b/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitChannelNetAttributesGetter.java @@ -5,11 +5,12 @@ package io.opentelemetry.javaagent.instrumentation.rabbitmq; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import javax.annotation.Nullable; -public class RabbitChannelNetAttributesExtractor - extends NetClientAttributesExtractor { +public class RabbitChannelNetAttributesGetter + implements NetClientAttributesGetter { + @Nullable @Override public String transport(ChannelAndMethod channelAndMethod, @Nullable Void unused) { diff --git a/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitReceiveNetAttributesExtractor.java b/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitReceiveNetAttributesGetter.java similarity index 86% rename from instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitReceiveNetAttributesExtractor.java rename to instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitReceiveNetAttributesGetter.java index 2945d5aa9d66..09cca9bbab54 100644 --- a/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitReceiveNetAttributesExtractor.java +++ b/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitReceiveNetAttributesGetter.java @@ -6,11 +6,12 @@ package io.opentelemetry.javaagent.instrumentation.rabbitmq; import com.rabbitmq.client.GetResponse; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import javax.annotation.Nullable; -public class RabbitReceiveNetAttributesExtractor - extends NetClientAttributesExtractor { +public class RabbitReceiveNetAttributesGetter + implements NetClientAttributesGetter { + @Nullable @Override public String transport(ReceiveRequest request, @Nullable GetResponse response) { diff --git a/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitSingletons.java b/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitSingletons.java index 63c4384c8c65..dea3d6053e6a 100644 --- a/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitSingletons.java +++ b/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitSingletons.java @@ -14,6 +14,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import java.util.ArrayList; import java.util.List; @@ -47,7 +48,8 @@ private static Instrumenter createChannelInstrumenter() return Instrumenter.builder( GlobalOpenTelemetry.get(), instrumentationName, ChannelAndMethod::getMethod) .addAttributesExtractors( - new RabbitChannelAttributesExtractor(), new RabbitChannelNetAttributesExtractor()) + new RabbitChannelAttributesExtractor(), + NetClientAttributesExtractor.create(new RabbitChannelNetAttributesGetter())) .newInstrumenter( channelAndMethod -> channelAndMethod.getMethod().equals("Channel.basicPublish") ? PRODUCER : CLIENT); @@ -56,7 +58,7 @@ private static Instrumenter createChannelInstrumenter() private static Instrumenter createReceiveInstrumenter() { List> extractors = new ArrayList<>(); extractors.add(new RabbitReceiveAttributesExtractor()); - extractors.add(new RabbitReceiveNetAttributesExtractor()); + extractors.add(NetClientAttributesExtractor.create(new RabbitReceiveNetAttributesGetter())); if (CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES) { extractors.add(new RabbitReceiveExperimentalAttributesExtractor()); } diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/RatpackTracingBuilder.java b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/RatpackTracingBuilder.java index 74b7bacdf58a..f64d0d28f15b 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/RatpackTracingBuilder.java +++ b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/RatpackTracingBuilder.java @@ -13,7 +13,8 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; -import io.opentelemetry.instrumentation.ratpack.internal.RatpackHttpNetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.ratpack.internal.RatpackHttpNetAttributesGetter; import io.opentelemetry.instrumentation.ratpack.internal.RatpackNetAttributesExtractor; import java.util.ArrayList; import java.util.List; @@ -88,14 +89,14 @@ public RatpackTracing build() { } private Instrumenter httpClientInstrumenter() { - RatpackHttpNetAttributesExtractor netAttributes = new RatpackHttpNetAttributesExtractor(); + RatpackHttpNetAttributesGetter netAttributes = new RatpackHttpNetAttributesGetter(); RatpackHttpClientAttributesExtractor httpAttributes = new RatpackHttpClientAttributesExtractor(capturedHttpHeaders); return Instrumenter.builder( openTelemetry, INSTRUMENTATION_NAME, HttpSpanNameExtractor.create(httpAttributes)) .setSpanStatusExtractor(HttpSpanStatusExtractor.create(httpAttributes)) - .addAttributesExtractor(netAttributes) + .addAttributesExtractor(NetClientAttributesExtractor.create(netAttributes)) .addAttributesExtractor(httpAttributes) .addAttributesExtractors(additionalHttpClientExtractors) .addRequestMetrics(HttpServerMetrics.get()) diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackHttpNetAttributesExtractor.java b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackHttpNetAttributesGetter.java similarity index 87% rename from instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackHttpNetAttributesExtractor.java rename to instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackHttpNetAttributesGetter.java index b2da2ff9a5b9..8dec58a36976 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackHttpNetAttributesExtractor.java +++ b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackHttpNetAttributesGetter.java @@ -5,14 +5,14 @@ package io.opentelemetry.instrumentation.ratpack.internal; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; import ratpack.http.client.HttpResponse; import ratpack.http.client.RequestSpec; -public final class RatpackHttpNetAttributesExtractor - extends NetClientAttributesExtractor { +public final class RatpackHttpNetAttributesGetter + implements NetClientAttributesGetter { @Override public String transport(RequestSpec request, @Nullable HttpResponse response) { return SemanticAttributes.NetTransportValues.IP_TCP; diff --git a/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettyNetClientAttributesExtractor.java b/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettyNetClientAttributesGetter.java similarity index 85% rename from instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettyNetClientAttributesExtractor.java rename to instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettyNetClientAttributesGetter.java index 49526c6f7382..067cc10feaa3 100644 --- a/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettyNetClientAttributesExtractor.java +++ b/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettyNetClientAttributesGetter.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.reactornetty.v1_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter; import java.net.InetSocketAddress; import java.net.SocketAddress; import javax.annotation.Nullable; @@ -13,8 +13,8 @@ import reactor.netty.http.client.HttpClientConfig; import reactor.netty.http.client.HttpClientResponse; -final class ReactorNettyNetClientAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { +final class ReactorNettyNetClientAttributesGetter + extends InetSocketAddressNetClientAttributesGetter { @Nullable @Override diff --git a/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettySingletons.java b/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettySingletons.java index d396c50c5e63..a723708738d2 100644 --- a/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettySingletons.java +++ b/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettySingletons.java @@ -13,6 +13,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.javaagent.instrumentation.netty.common.client.NettyClientInstrumenterFactory; import io.opentelemetry.javaagent.instrumentation.netty.common.client.NettyConnectionInstrumenter; import reactor.netty.http.client.HttpClientConfig; @@ -32,8 +33,8 @@ public final class ReactorNettySingletons { static { ReactorNettyHttpClientAttributesExtractor httpAttributesExtractor = new ReactorNettyHttpClientAttributesExtractor(); - ReactorNettyNetClientAttributesExtractor netAttributesExtractor = - new ReactorNettyNetClientAttributesExtractor(); + ReactorNettyNetClientAttributesGetter netAttributesGetter = + new ReactorNettyNetClientAttributesGetter(); INSTRUMENTER = Instrumenter.builder( @@ -42,8 +43,8 @@ public final class ReactorNettySingletons { HttpSpanNameExtractor.create(httpAttributesExtractor)) .setSpanStatusExtractor(HttpSpanStatusExtractor.create(httpAttributesExtractor)) .addAttributesExtractor(httpAttributesExtractor) - .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(NetClientAttributesExtractor.create(netAttributesGetter)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter)) .addRequestMetrics(HttpClientMetrics.get()) // headers are injected in ResponseReceiverInstrumenter .newInstrumenter(SpanKindExtractor.alwaysClient()); diff --git a/instrumentation/redisson-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonNetAttributesExtractor.java b/instrumentation/redisson-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonNetAttributesGetter.java similarity index 76% rename from instrumentation/redisson-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonNetAttributesExtractor.java rename to instrumentation/redisson-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonNetAttributesGetter.java index aad5aaf669b9..0700622183e0 100644 --- a/instrumentation/redisson-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonNetAttributesExtractor.java +++ b/instrumentation/redisson-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonNetAttributesGetter.java @@ -5,12 +5,12 @@ package io.opentelemetry.javaagent.instrumentation.redisson; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter; import java.net.InetSocketAddress; import javax.annotation.Nullable; -final class RedissonNetAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { +final class RedissonNetAttributesGetter + extends InetSocketAddressNetClientAttributesGetter { @Override public InetSocketAddress getAddress(RedissonRequest request, @Nullable Void unused) { diff --git a/instrumentation/redisson-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonSingletons.java b/instrumentation/redisson-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonSingletons.java index 42a3a883cb2a..c861b82f4cca 100644 --- a/instrumentation/redisson-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonSingletons.java +++ b/instrumentation/redisson-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonSingletons.java @@ -11,6 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbSpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; public final class RedissonSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.redisson-3.0"; @@ -20,14 +21,15 @@ public final class RedissonSingletons { static { DbAttributesExtractor dbAttributesExtractor = new RedissonDbAttributesExtractor(); - RedissonNetAttributesExtractor netAttributesExtractor = new RedissonNetAttributesExtractor(); + NetClientAttributesExtractor netAttributeExtractor = + NetClientAttributesExtractor.create(new RedissonNetAttributesGetter()); SpanNameExtractor spanName = DbSpanNameExtractor.create(dbAttributesExtractor); INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanName) .addAttributesExtractor(dbAttributesExtractor) - .addAttributesExtractor(netAttributesExtractor) + .addAttributesExtractor(netAttributeExtractor) .newInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/spring/spring-webflux-5.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/client/SpringWebfluxNetAttributesExtractor.java b/instrumentation/spring/spring-webflux-5.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/client/SpringWebfluxNetAttributesGetter.java similarity index 88% rename from instrumentation/spring/spring-webflux-5.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/client/SpringWebfluxNetAttributesExtractor.java rename to instrumentation/spring/spring-webflux-5.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/client/SpringWebfluxNetAttributesGetter.java index dd0c6619b035..04517b075374 100644 --- a/instrumentation/spring/spring-webflux-5.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/client/SpringWebfluxNetAttributesExtractor.java +++ b/instrumentation/spring/spring-webflux-5.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/client/SpringWebfluxNetAttributesGetter.java @@ -5,14 +5,14 @@ package io.opentelemetry.instrumentation.spring.webflux.client; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.annotation.Nullable; import org.springframework.web.reactive.function.client.ClientRequest; import org.springframework.web.reactive.function.client.ClientResponse; -final class SpringWebfluxNetAttributesExtractor - extends NetClientAttributesExtractor { +final class SpringWebfluxNetAttributesGetter + implements NetClientAttributesGetter { @Override public String transport(ClientRequest request, @Nullable ClientResponse response) { diff --git a/instrumentation/spring/spring-webflux-5.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/client/SpringWebfluxTracingBuilder.java b/instrumentation/spring/spring-webflux-5.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/client/SpringWebfluxTracingBuilder.java index 89b46039bd81..4e0d37b48356 100644 --- a/instrumentation/spring/spring-webflux-5.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/client/SpringWebfluxTracingBuilder.java +++ b/instrumentation/spring/spring-webflux-5.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/client/SpringWebfluxTracingBuilder.java @@ -17,6 +17,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import java.util.ArrayList; import java.util.List; import org.springframework.web.reactive.function.client.ClientRequest; @@ -63,8 +64,9 @@ public SpringWebfluxTracingBuilder captureHttpHeaders(CapturedHttpHeaders captur public SpringWebfluxTracing build() { SpringWebfluxHttpAttributesExtractor httpAttributesExtractor = new SpringWebfluxHttpAttributesExtractor(capturedHttpHeaders); - SpringWebfluxNetAttributesExtractor netAttributesExtractor = - new SpringWebfluxNetAttributesExtractor(); + SpringWebfluxNetAttributesGetter attributesGetter = new SpringWebfluxNetAttributesGetter(); + NetClientAttributesExtractor attributesExtractor = + NetClientAttributesExtractor.create(attributesGetter); InstrumenterBuilder builder = Instrumenter.builder( @@ -73,8 +75,8 @@ public SpringWebfluxTracing build() { HttpSpanNameExtractor.create(httpAttributesExtractor)) .setSpanStatusExtractor(HttpSpanStatusExtractor.create(httpAttributesExtractor)) .addAttributesExtractor(httpAttributesExtractor) - .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(attributesExtractor) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(attributesGetter)) .addAttributesExtractors(additionalExtractors) .addRequestMetrics(HttpClientMetrics.get()); diff --git a/instrumentation/vertx/vertx-http-client/vertx-http-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/client/Vertx4NetAttributesExtractor.java b/instrumentation/vertx/vertx-http-client/vertx-http-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/client/Vertx4NetAttributesGetter.java similarity index 88% rename from instrumentation/vertx/vertx-http-client/vertx-http-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/client/Vertx4NetAttributesExtractor.java rename to instrumentation/vertx/vertx-http-client/vertx-http-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/client/Vertx4NetAttributesGetter.java index b1137c064d1f..c85f74962c39 100644 --- a/instrumentation/vertx/vertx-http-client/vertx-http-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/client/Vertx4NetAttributesExtractor.java +++ b/instrumentation/vertx/vertx-http-client/vertx-http-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/client/Vertx4NetAttributesGetter.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.vertx.v4_0.client; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import io.vertx.core.http.HttpClientRequest; import io.vertx.core.http.HttpClientResponse; import javax.annotation.Nullable; -final class Vertx4NetAttributesExtractor - extends NetClientAttributesExtractor { +final class Vertx4NetAttributesGetter + implements NetClientAttributesGetter { @Override public String transport(HttpClientRequest request, @Nullable HttpClientResponse response) { diff --git a/instrumentation/vertx/vertx-http-client/vertx-http-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/client/VertxClientSingletons.java b/instrumentation/vertx/vertx-http-client/vertx-http-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/client/VertxClientSingletons.java index 331ab830f220..90fecaba9f78 100644 --- a/instrumentation/vertx/vertx-http-client/vertx-http-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/client/VertxClientSingletons.java +++ b/instrumentation/vertx/vertx-http-client/vertx-http-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/client/VertxClientSingletons.java @@ -16,7 +16,7 @@ public final class VertxClientSingletons { VertxClientInstrumenterFactory.create( "io.opentelemetry.vertx-http-client-4.0", new Vertx4HttpAttributesExtractor(), - new Vertx4NetAttributesExtractor()); + new Vertx4NetAttributesGetter()); public static Instrumenter instrumenter() { return INSTRUMENTER; diff --git a/instrumentation/vertx/vertx-http-client/vertx-http-client-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/client/VertxClientInstrumenterFactory.java b/instrumentation/vertx/vertx-http-client/vertx-http-client-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/client/VertxClientInstrumenterFactory.java index 8fdeb8c73199..6399ba7ac5cc 100644 --- a/instrumentation/vertx/vertx-http-client/vertx-http-client-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/client/VertxClientInstrumenterFactory.java +++ b/instrumentation/vertx/vertx-http-client/vertx-http-client-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/client/VertxClientInstrumenterFactory.java @@ -13,6 +13,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.vertx.core.http.HttpClientRequest; import io.vertx.core.http.HttpClientResponse; import javax.annotation.Nullable; @@ -23,8 +24,7 @@ public static Instrumenter create( String instrumentationName, AbstractVertxHttpAttributesExtractor httpAttributesExtractor, @Nullable - NetClientAttributesExtractor - netAttributesExtractor) { + NetClientAttributesGetter netAttributesGetter) { InstrumenterBuilder builder = Instrumenter.builder( @@ -35,10 +35,12 @@ public static Instrumenter create( .addAttributesExtractor(httpAttributesExtractor) .addRequestMetrics(HttpClientMetrics.get()); - if (netAttributesExtractor != null) { + if (netAttributesGetter != null) { + NetClientAttributesExtractor netAttributesExtractor = + NetClientAttributesExtractor.create(netAttributesGetter); builder .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)); + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter)); } return builder.newClientInstrumenter(new HttpRequestHeaderSetter());