From 8ed80494522259716b882854276a2ee2147b98f8 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 3 Oct 2021 11:10:58 -0700 Subject: [PATCH 01/26] Net Extractors --- .../benchmark/InstrumenterBenchmark.java | 2 +- ...etSocketAddressNetAttributesExtractor.java | 14 ++-- ...AddressNetResponseAttributesExtractor.java | 67 ++++++++++++++++ .../net/NetAttributesExtractor.java | 28 ++----- .../net/NetResponseAttributesExtractor.java | 74 +++++++++++++++++ .../net/NetAttributesExtractorTest.java | 50 +++++++++++- .../internal/DubboNetAttributesExtractor.java | 2 +- ...HttpAsyncClientNetAttributesExtractor.java | 7 +- ...pacheHttpClientNetAttributesExtractor.java | 6 +- ...pacheHttpClientNetAttributesExtractor.java | 7 +- ...pacheHttpClientNetAttributesExtractor.java | 6 +- ...pacheHttpClientNetAttributesExtractor.java | 6 +- .../ArmeriaNetAttributesExtractor.java | 2 +- ...AsyncHttpClientNetAttributesExtractor.java | 6 +- ...AsyncHttpClientNetAttributesExtractor.java | 4 +- .../v2_0/AsyncHttpClientSingletons.java | 9 ++- .../v3_0/CassandraNetAttributesExtractor.java | 4 +- .../v4_0/CassandraNetAttributesExtractor.java | 4 +- .../ElasticsearchRestInstrumenterFactory.java | 9 ++- ...chRestNetResponseAttributesExtractor.java} | 6 +- .../Elasticsearch5TransportSingletons.java | 4 +- .../Elasticsearch53TransportSingletons.java | 4 +- ...earch6TransportNetAttributesExtractor.java | 5 +- ...nsportNetResponseAttributesExtractor.java} | 6 +- ...ticsearchTransportInstrumenterFactory.java | 3 +- ...oogleHttpClientNetAttributesExtractor.java | 6 +- .../internal/GrpcNetAttributesExtractor.java | 2 +- .../HttpUrlNetAttributesExtractor.java | 6 +- .../JdkHttpNetAttributesExtractor.java | 8 +- .../JaxRsClientNetAttributesExtractor.java | 6 +- .../JaxRsClientNetAttributesExtractor.java | 8 +- .../ResteasyClientNetAttributesExtractor.java | 6 +- .../internal/JdbcNetAttributesExtractor.java | 6 +- .../v1_4/JedisNetAttributesExtractor.java | 6 +- .../v3_0/JedisNetAttributesExtractor.java | 2 +- ...JettyHttpClientNetAttributesExtractor.java | 6 +- .../KubernetesNetAttributesExtractor.java | 6 +- .../LettuceConnectNetAttributesExtractor.java | 6 +- .../LettuceConnectNetAttributesExtractor.java | 6 +- .../v2_2/OkHttp2NetAttributesExtractor.java | 6 +- .../OkHttpNetAttributesExtractor.java | 6 +- .../PlayWsClientNetAttributesExtractor.java | 4 +- .../playws/PlayWsClientSingletons.java | 5 +- .../RatpackNetAttributesExtractor.java | 6 +- .../RedissonNetAttributesExtractor.java | 2 +- .../v1_0/RestletNetAttributesExtractor.java | 6 +- .../ServletNetAttributesExtractor.java | 12 +-- .../web/SpringWebNetAttributesExtractor.java | 9 +-- .../SpringWebMvcNetAttributesExtractor.java | 8 +- .../common/TomcatNetAttributesExtractor.java | 6 +- .../UndertowNetAttributesExtractor.java | 3 +- .../PeerServiceAttributesExtractor.java | 20 +++-- ...eerServiceResponseAttributesExtractor.java | 80 +++++++++++++++++++ 53 files changed, 413 insertions(+), 175 deletions(-) create mode 100644 instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetResponseAttributesExtractor.java create mode 100644 instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetResponseAttributesExtractor.java rename instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/{ElasticsearchRestNetAttributesExtractor.java => ElasticsearchRestNetResponseAttributesExtractor.java} (88%) rename instrumentation/elasticsearch/elasticsearch-transport-common/library/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/{ElasticTransportNetAttributesExtractor.java => ElasticTransportNetResponseAttributesExtractor.java} (88%) create mode 100644 javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceResponseAttributesExtractor.java diff --git a/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java b/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java index dae6b51575f1..e0de56a3757d 100644 --- a/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java +++ b/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java @@ -111,7 +111,7 @@ static class ConstantNetAttributesExtractor InetSocketAddress.createUnresolved("localhost", 8080); @Override - public @Nullable InetSocketAddress getAddress(Void unused, @Nullable Void unused2) { + public @Nullable InetSocketAddress getAddress(Void unused) { return ADDRESS; } diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesExtractor.java index 2047b0239e67..5836e6ff98a5 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesExtractor.java @@ -25,12 +25,12 @@ public abstract class InetSocketAddressNetAttributesExtractor * phases of processing. */ @Nullable - public abstract InetSocketAddress getAddress(REQUEST request, @Nullable RESPONSE response); + public abstract InetSocketAddress getAddress(REQUEST request); @Override @Nullable - public final String peerName(REQUEST request, @Nullable RESPONSE response) { - InetSocketAddress address = getAddress(request, response); + public final String peerName(REQUEST request) { + InetSocketAddress address = getAddress(request); if (address == null) { return null; } @@ -42,8 +42,8 @@ public final String peerName(REQUEST request, @Nullable RESPONSE response) { @Override @Nullable - public final Integer peerPort(REQUEST request, @Nullable RESPONSE response) { - InetSocketAddress address = getAddress(request, response); + public final Integer peerPort(REQUEST request) { + InetSocketAddress address = getAddress(request); if (address == null) { return null; } @@ -52,8 +52,8 @@ public final Integer peerPort(REQUEST request, @Nullable RESPONSE response) { @Override @Nullable - public final String peerIp(REQUEST request, @Nullable RESPONSE response) { - InetSocketAddress address = getAddress(request, response); + public final String peerIp(REQUEST request) { + InetSocketAddress address = getAddress(request); if (address == null) { return null; } diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetResponseAttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetResponseAttributesExtractor.java new file mode 100644 index 000000000000..a241d43a3716 --- /dev/null +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetResponseAttributesExtractor.java @@ -0,0 +1,67 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.api.instrumenter.net; + +import java.net.InetAddress; +import java.net.InetSocketAddress; +import org.checkerframework.checker.nullness.qual.Nullable; + +/** + * Extractor of Network + * attributes from a {@link InetSocketAddress}. Most network libraries will provide access to a + * {@link InetSocketAddress} so this is a convenient alternative to {@link + * NetResponseAttributesExtractor}. There is no meaning to implement both in the same + * instrumentation. + */ +public abstract class InetSocketAddressNetResponseAttributesExtractor + extends NetResponseAttributesExtractor { + + /** + * This method will be called twice: both when the request starts ({@code response} is always null + * then) and when the response ends. This way it is possible to capture net attributes in both + * phases of processing. + */ + @Nullable + public abstract InetSocketAddress getAddress(REQUEST request, RESPONSE response); + + @Override + @Nullable + public final String peerName(REQUEST request, RESPONSE response) { + InetSocketAddress address = getAddress(request, response); + if (address == null) { + return null; + } + if (address.getAddress() != null) { + return address.getAddress().getHostName(); + } + return address.getHostString(); + } + + @Override + @Nullable + public final Integer peerPort(REQUEST request, RESPONSE response) { + InetSocketAddress address = getAddress(request, response); + if (address == null) { + return null; + } + return address.getPort(); + } + + @Override + @Nullable + public final String peerIp(REQUEST request, RESPONSE response) { + InetSocketAddress address = getAddress(request, response); + if (address == null) { + return null; + } + InetAddress remoteAddress = address.getAddress(); + if (remoteAddress != null) { + return remoteAddress.getHostAddress(); + } + return null; + } +} diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesExtractor.java index 1a19303c5587..ff8537a27d29 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesExtractor.java @@ -23,15 +23,15 @@ public abstract class NetAttributesExtractor protected final void onStart(AttributesBuilder attributes, REQUEST request) { set(attributes, SemanticAttributes.NET_TRANSPORT, transport(request)); - String peerIp = peerIp(request, null); - String peerName = peerName(request, null); + String peerIp = peerIp(request); + String peerName = peerName(request); if (peerName != null && !peerName.equals(peerIp)) { set(attributes, SemanticAttributes.NET_PEER_NAME, peerName); } set(attributes, SemanticAttributes.NET_PEER_IP, peerIp); - Integer peerPort = peerPort(request, null); + Integer peerPort = peerPort(request); if (peerPort != null) { set(attributes, SemanticAttributes.NET_PEER_PORT, (long) peerPort); } @@ -42,21 +42,7 @@ protected final void onEnd( AttributesBuilder attributes, REQUEST request, @Nullable RESPONSE response, - @Nullable Throwable error) { - - String peerIp = peerIp(request, response); - String peerName = 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); - if (peerPort != null) { - set(attributes, SemanticAttributes.NET_PEER_PORT, (long) peerPort); - } - } + @Nullable Throwable error) {} @Nullable public abstract String transport(REQUEST request); @@ -67,7 +53,7 @@ protected final void onEnd( * phases of processing. */ @Nullable - public abstract String peerName(REQUEST request, @Nullable RESPONSE response); + public abstract String peerName(REQUEST request); /** * This method will be called twice: both when the request starts ({@code response} is always null @@ -75,7 +61,7 @@ protected final void onEnd( * phases of processing. */ @Nullable - public abstract Integer peerPort(REQUEST request, @Nullable RESPONSE response); + public abstract Integer peerPort(REQUEST request); /** * This method will be called twice: both when the request starts ({@code response} is always null @@ -83,5 +69,5 @@ protected final void onEnd( * phases of processing. */ @Nullable - public abstract String peerIp(REQUEST request, @Nullable RESPONSE response); + public abstract String peerIp(REQUEST request); } diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetResponseAttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetResponseAttributesExtractor.java new file mode 100644 index 000000000000..c3b8bf1ea0ce --- /dev/null +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetResponseAttributesExtractor.java @@ -0,0 +1,74 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.api.instrumenter.net; + +import io.opentelemetry.api.common.AttributesBuilder; +import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; +import org.checkerframework.checker.nullness.qual.Nullable; + +/** + * 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 InetSocketAddressNetAttributesExtractor}. + */ +public abstract class NetResponseAttributesExtractor + extends AttributesExtractor { + + @Override + protected final void onStart(AttributesBuilder attributes, REQUEST request) { + set(attributes, SemanticAttributes.NET_TRANSPORT, transport(request)); + } + + @Override + protected final void onEnd( + AttributesBuilder attributes, + REQUEST request, + @Nullable RESPONSE response, + @Nullable Throwable error) { + + String peerIp = peerIp(request, response); + String peerName = 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); + if (peerPort != null) { + set(attributes, SemanticAttributes.NET_PEER_PORT, (long) peerPort); + } + } + + @Nullable + public abstract String transport(REQUEST request); + + /** + * This method will be called twice: both when the request starts ({@code response} is always null + * then) and when the response ends. This way it is possible to capture net attributes in both + * phases of processing. + */ + @Nullable + public abstract String peerName(REQUEST request, @Nullable RESPONSE response); + + /** + * This method will be called twice: both when the request starts ({@code response} is always null + * then) and when the response ends. This way it is possible to capture net attributes in both + * phases of processing. + */ + @Nullable + public abstract Integer peerPort(REQUEST request, @Nullable RESPONSE response); + + /** + * This method will be called twice: both when the request starts ({@code response} is always null + * then) and when the response ends. This way it is possible to capture net attributes in both + * phases of processing. + */ + @Nullable + public abstract String peerIp(REQUEST request, @Nullable RESPONSE response); +} diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesExtractorTest.java index f7db8ba52615..bcd300945e62 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesExtractorTest.java @@ -25,6 +25,30 @@ public String transport(Map request) { return request.get("transport"); } + @Override + public String peerName(Map request) { + return request.get("peerName"); + } + + @Override + public Integer peerPort(Map request) { + return Integer.valueOf(request.get("peerPort")); + } + + @Override + public String peerIp(Map request) { + return request.get("peerIp"); + } + } + + static class TestNetResponseAttributesExtractor + extends NetResponseAttributesExtractor, Map> { + + @Override + public String transport(Map request) { + return request.get("transport"); + } + @Override public String peerName(Map request, Map response) { if (response != null) { @@ -59,12 +83,36 @@ void normal() { request.put("peerPort", "123"); request.put("peerIp", "1.2.3.4"); + TestNetAttributesExtractor extractor = new TestNetAttributesExtractor(); + + // when + AttributesBuilder startAttributes = Attributes.builder(); + extractor.onStart(startAttributes, request); + + // then + assertThat(startAttributes.build()) + .containsOnly( + entry(SemanticAttributes.NET_TRANSPORT, "TCP"), + entry(SemanticAttributes.NET_PEER_NAME, "github.com"), + entry(SemanticAttributes.NET_PEER_PORT, 123L), + entry(SemanticAttributes.NET_PEER_IP, "1.2.3.4")); + } + + @Test + void responseAttributes() { + // given + Map request = new HashMap<>(); + request.put("transport", "TCP"); + request.put("peerName", "github.com"); + request.put("peerPort", "123"); + request.put("peerIp", "1.2.3.4"); + Map response = new HashMap<>(); response.put("peerName", "opentelemetry.io"); response.put("peerPort", "42"); response.put("peerIp", "4.3.2.1"); - TestNetAttributesExtractor extractor = new TestNetAttributesExtractor(); + TestNetResponseAttributesExtractor extractor = new TestNetResponseAttributesExtractor(); // when AttributesBuilder startAttributes = Attributes.builder(); diff --git a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetAttributesExtractor.java b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetAttributesExtractor.java index 2c42ab5c4081..42b426c2aff6 100644 --- a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetAttributesExtractor.java +++ b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetAttributesExtractor.java @@ -15,7 +15,7 @@ public final class DubboNetAttributesExtractor extends InetSocketAddressNetAttributesExtractor { @Override - public @Nullable InetSocketAddress getAddress(DubboRequest request, @Nullable Result result) { + public @Nullable InetSocketAddress getAddress(DubboRequest request) { return request.context().getRemoteAddress(); } 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/ApacheHttpAsyncClientNetAttributesExtractor.java index 7233ae17c35b..afeccee74d6c 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/ApacheHttpAsyncClientNetAttributesExtractor.java @@ -19,18 +19,17 @@ public String transport(ApacheHttpClientRequest request) { } @Override - public @Nullable String peerName( - ApacheHttpClientRequest request, @Nullable HttpResponse response) { + public @Nullable String peerName(ApacheHttpClientRequest request) { return request.getPeerName(); } @Override - public Integer peerPort(ApacheHttpClientRequest request, @Nullable HttpResponse response) { + public Integer peerPort(ApacheHttpClientRequest request) { return request.getPeerPort(); } @Override - public @Nullable String peerIp(ApacheHttpClientRequest request, @Nullable HttpResponse response) { + public @Nullable String peerIp(ApacheHttpClientRequest request) { return null; } } 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/ApacheHttpClientNetAttributesExtractor.java index d8c1ce772d0a..88e5b7b2e294 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/ApacheHttpClientNetAttributesExtractor.java @@ -20,19 +20,19 @@ public String transport(HttpMethod request) { } @Override - public @Nullable String peerName(HttpMethod request, @Nullable HttpMethod response) { + public @Nullable String peerName(HttpMethod request) { HostConfiguration hostConfiguration = request.getHostConfiguration(); return hostConfiguration != null ? hostConfiguration.getHost() : null; } @Override - public @Nullable Integer peerPort(HttpMethod request, @Nullable HttpMethod response) { + public @Nullable Integer peerPort(HttpMethod request) { HostConfiguration hostConfiguration = request.getHostConfiguration(); return hostConfiguration != null ? hostConfiguration.getPort() : null; } @Override - public @Nullable String peerIp(HttpMethod request, @Nullable HttpMethod response) { + public @Nullable String peerIp(HttpMethod request) { return null; } } 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/ApacheHttpClientNetAttributesExtractor.java index 31684c16739c..9026f6fbe5a6 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/ApacheHttpClientNetAttributesExtractor.java @@ -19,18 +19,17 @@ public String transport(ApacheHttpClientRequest request) { } @Override - public @Nullable String peerName( - ApacheHttpClientRequest request, @Nullable HttpResponse response) { + public @Nullable String peerName(ApacheHttpClientRequest request) { return request.getPeerName(); } @Override - public Integer peerPort(ApacheHttpClientRequest request, @Nullable HttpResponse response) { + public Integer peerPort(ApacheHttpClientRequest request) { return request.getPeerPort(); } @Override - public @Nullable String peerIp(ApacheHttpClientRequest request, @Nullable HttpResponse response) { + public @Nullable String peerIp(ApacheHttpClientRequest request) { return null; } } 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/ApacheHttpClientNetAttributesExtractor.java index 69458f393cef..9545dc5e50d4 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/ApacheHttpClientNetAttributesExtractor.java @@ -20,19 +20,19 @@ public String transport(ApacheHttpClientRequest request) { @Override @Nullable - public String peerName(ApacheHttpClientRequest request, @Nullable HttpResponse response) { + public String peerName(ApacheHttpClientRequest request) { return request.getPeerName(); } @Override @Nullable - public Integer peerPort(ApacheHttpClientRequest request, @Nullable HttpResponse response) { + public Integer peerPort(ApacheHttpClientRequest request) { return request.getPeerPort(); } @Override @Nullable - public String peerIp(ApacheHttpClientRequest request, @Nullable HttpResponse response) { + public String peerIp(ApacheHttpClientRequest request) { return null; } } 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/ApacheHttpClientNetAttributesExtractor.java index 951330a4a47b..d954d2d70399 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/ApacheHttpClientNetAttributesExtractor.java @@ -25,12 +25,12 @@ public String transport(ClassicHttpRequest request) { } @Override - public @Nullable String peerName(ClassicHttpRequest request, @Nullable HttpResponse response) { + public @Nullable String peerName(ClassicHttpRequest request) { return request.getAuthority().getHostName(); } @Override - public Integer peerPort(ClassicHttpRequest request, @Nullable HttpResponse response) { + public Integer peerPort(ClassicHttpRequest request) { int port = request.getAuthority().getPort(); if (port != -1) { return port; @@ -51,7 +51,7 @@ public Integer peerPort(ClassicHttpRequest request, @Nullable HttpResponse respo } @Override - public @Nullable String peerIp(ClassicHttpRequest request, @Nullable HttpResponse response) { + public @Nullable String peerIp(ClassicHttpRequest request) { return null; } } diff --git a/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetAttributesExtractor.java b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetAttributesExtractor.java index d7ae326e66ae..163e6b288358 100644 --- a/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetAttributesExtractor.java +++ b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetAttributesExtractor.java @@ -23,7 +23,7 @@ public String transport(RequestContext ctx) { @Override @Nullable - public InetSocketAddress getAddress(RequestContext ctx, @Nullable RequestLog requestLog) { + public InetSocketAddress getAddress(RequestContext ctx) { SocketAddress address = ctx.remoteAddress(); if (address instanceof InetSocketAddress) { return (InetSocketAddress) address; 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/AsyncHttpClientNetAttributesExtractor.java index b4dc9a99f2f4..e5776d9e96e4 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/AsyncHttpClientNetAttributesExtractor.java @@ -20,18 +20,18 @@ public String transport(Request request) { } @Override - public String peerName(Request request, @Nullable Response response) { + public String peerName(Request request) { return request.getUri().getHost(); } @Override - public Integer peerPort(Request request, @Nullable Response response) { + public Integer peerPort(Request request) { return request.getUri().getPort(); } @Override @Nullable - public String peerIp(Request request, @Nullable Response response) { + public String peerIp(Request request) { return null; } } 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/AsyncHttpClientNetAttributesExtractor.java index 7af67b2d8d66..7ba54f2c481f 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/AsyncHttpClientNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.asynchttpclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetResponseAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import org.asynchttpclient.Response; import org.checkerframework.checker.nullness.qual.Nullable; final class AsyncHttpClientNetAttributesExtractor - extends InetSocketAddressNetAttributesExtractor { + extends InetSocketAddressNetResponseAttributesExtractor { @Override public String transport(RequestContext requestContext) { 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 6f0fad05f6e7..c802785097d5 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 @@ -13,8 +13,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.api.instrumenter.net.NetAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetResponseAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceResponseAttributesExtractor; import org.asynchttpclient.Response; public final class AsyncHttpClientSingletons { @@ -29,7 +29,7 @@ public final class AsyncHttpClientSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetAttributesExtractor netAttributesExtractor = + NetResponseAttributesExtractor netAttributesExtractor = new AsyncHttpClientNetAttributesExtractor(); INSTRUMENTER = @@ -38,7 +38,8 @@ public final class AsyncHttpClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceResponseAttributesExtractor.create(netAttributesExtractor)) .addAttributesExtractor(new AsyncHttpClientAdditionalAttributesExtractor()) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); 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/CassandraNetAttributesExtractor.java index 191fbe1a65ad..456c8f451197 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/CassandraNetAttributesExtractor.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.InetSocketAddressNetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetResponseAttributesExtractor; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; final class CassandraNetAttributesExtractor - extends InetSocketAddressNetAttributesExtractor { + extends InetSocketAddressNetResponseAttributesExtractor { @Override @Nullable 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/CassandraNetAttributesExtractor.java index 73f0193f4e0b..24b45be65328 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/CassandraNetAttributesExtractor.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.InetSocketAddressNetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetResponseAttributesExtractor; import java.net.InetSocketAddress; import java.net.SocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; final class CassandraNetAttributesExtractor - extends InetSocketAddressNetAttributesExtractor { + extends InetSocketAddressNetResponseAttributesExtractor { @Override @Nullable 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 af4d1d96f88d..c1b40e3d86af 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 @@ -10,7 +10,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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceResponseAttributesExtractor; import org.elasticsearch.client.Response; public final class ElasticsearchRestInstrumenterFactory { @@ -19,14 +19,15 @@ public static Instrumenter create(String instrumentationName) ElasticsearchRestAttributesExtractor attributesExtractor = new ElasticsearchRestAttributesExtractor(); SpanNameExtractor spanNameExtractor = DbSpanNameExtractor.create(attributesExtractor); - ElasticsearchRestNetAttributesExtractor netAttributesExtractor = - new ElasticsearchRestNetAttributesExtractor(); + ElasticsearchRestNetResponseAttributesExtractor netAttributesExtractor = + new ElasticsearchRestNetResponseAttributesExtractor(); return Instrumenter.newBuilder( GlobalOpenTelemetry.get(), instrumentationName, spanNameExtractor) .addAttributesExtractor(attributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceResponseAttributesExtractor.create(netAttributesExtractor)) .newInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestNetAttributesExtractor.java b/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestNetResponseAttributesExtractor.java similarity index 88% rename from instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestNetAttributesExtractor.java rename to instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestNetResponseAttributesExtractor.java index bda81598bd65..e3ae6b07dbf2 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestNetAttributesExtractor.java +++ b/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestNetResponseAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.rest; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetResponseAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; import org.elasticsearch.client.Response; -final class ElasticsearchRestNetAttributesExtractor - extends NetAttributesExtractor { +final class ElasticsearchRestNetResponseAttributesExtractor + extends NetResponseAttributesExtractor { @Override public String transport(String s) { 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 bde95679c6ad..758330b64933 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,7 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.v5_0; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportNetAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportNetResponseAttributesExtractor; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportRequest; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticsearchTransportInstrumenterFactory; import org.elasticsearch.action.ActionResponse; @@ -17,7 +17,7 @@ public final class Elasticsearch5TransportSingletons { ElasticsearchTransportInstrumenterFactory.create( "io.opentelemetry.elasticsearch-transport-5.0", new Elasticsearch5TransportExperimentalAttributesExtractor(), - new ElasticTransportNetAttributesExtractor()); + new ElasticTransportNetResponseAttributesExtractor()); 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 e4244824eff9..8b0183eaa1b1 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,7 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.v5_3; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportNetAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportNetResponseAttributesExtractor; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportRequest; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticsearchTransportInstrumenterFactory; import org.elasticsearch.action.ActionResponse; @@ -17,7 +17,7 @@ public final class Elasticsearch53TransportSingletons { ElasticsearchTransportInstrumenterFactory.create( "io.opentelemetry.elasticsearch-transport-5.3", new Elasticsearch53TransportExperimentalAttributesExtractor(), - new ElasticTransportNetAttributesExtractor()); + new ElasticTransportNetResponseAttributesExtractor()); 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/Elasticsearch6TransportNetAttributesExtractor.java index 324e4be35ad6..6f87c729dbfa 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/Elasticsearch6TransportNetAttributesExtractor.java @@ -5,14 +5,15 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.v6_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetResponseAttributesExtractor; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportRequest; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; import org.elasticsearch.action.ActionResponse; public class Elasticsearch6TransportNetAttributesExtractor - extends InetSocketAddressNetAttributesExtractor { + extends InetSocketAddressNetResponseAttributesExtractor< + ElasticTransportRequest, ActionResponse> { @Override public @Nullable String transport(ElasticTransportRequest elasticTransportRequest) { return null; diff --git a/instrumentation/elasticsearch/elasticsearch-transport-common/library/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetAttributesExtractor.java b/instrumentation/elasticsearch/elasticsearch-transport-common/library/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetResponseAttributesExtractor.java similarity index 88% rename from instrumentation/elasticsearch/elasticsearch-transport-common/library/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetAttributesExtractor.java rename to instrumentation/elasticsearch/elasticsearch-transport-common/library/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetResponseAttributesExtractor.java index ec60e438038c..cb46911a58d2 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-common/library/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetAttributesExtractor.java +++ b/instrumentation/elasticsearch/elasticsearch-transport-common/library/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetResponseAttributesExtractor.java @@ -5,12 +5,12 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetResponseAttributesExtractor; import org.checkerframework.checker.nullness.qual.Nullable; import org.elasticsearch.action.ActionResponse; -public class ElasticTransportNetAttributesExtractor - extends NetAttributesExtractor { +public class ElasticTransportNetResponseAttributesExtractor + extends NetResponseAttributesExtractor { @Override public @Nullable String transport(ElasticTransportRequest elasticTransportRequest) { return null; diff --git a/instrumentation/elasticsearch/elasticsearch-transport-common/library/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticsearchTransportInstrumenterFactory.java b/instrumentation/elasticsearch/elasticsearch-transport-common/library/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticsearchTransportInstrumenterFactory.java index e80a8f585dfc..100604898874 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-common/library/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticsearchTransportInstrumenterFactory.java +++ b/instrumentation/elasticsearch/elasticsearch-transport-common/library/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticsearchTransportInstrumenterFactory.java @@ -12,7 +12,6 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbSpanNameExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; import org.elasticsearch.action.ActionResponse; public final class ElasticsearchTransportInstrumenterFactory { @@ -23,7 +22,7 @@ public final class ElasticsearchTransportInstrumenterFactory { public static Instrumenter create( String instrumentationName, AttributesExtractor experimentalAttributesExtractor, - NetAttributesExtractor netAttributesExtractor) { + AttributesExtractor netAttributesExtractor) { ElasticsearchTransportAttributesExtractor attributesExtractor = new ElasticsearchTransportAttributesExtractor(); 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/GoogleHttpClientNetAttributesExtractor.java index a69f7f96436e..52ffae2435cb 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/GoogleHttpClientNetAttributesExtractor.java @@ -20,12 +20,12 @@ public String transport(HttpRequest request) { } @Override - public @Nullable String peerName(HttpRequest request, @Nullable HttpResponse response) { + public @Nullable String peerName(HttpRequest request) { return request.getUrl().getHost(); } @Override - public Integer peerPort(HttpRequest request, @Nullable HttpResponse response) { + public Integer peerPort(HttpRequest request) { int port = request.getUrl().getPort(); if (port != -1) { return port; @@ -34,7 +34,7 @@ public Integer peerPort(HttpRequest request, @Nullable HttpResponse response) { } @Override - public @Nullable String peerIp(HttpRequest request, @Nullable HttpResponse response) { + public @Nullable String peerIp(HttpRequest request) { return null; } } diff --git a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetAttributesExtractor.java b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetAttributesExtractor.java index 4f5b35f4b008..e5431c9fce82 100644 --- a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetAttributesExtractor.java +++ b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetAttributesExtractor.java @@ -17,7 +17,7 @@ public final class GrpcNetAttributesExtractor extends InetSocketAddressNetAttributesExtractor { @Override @Nullable - public InetSocketAddress getAddress(GrpcRequest request, @Nullable Status status) { + public InetSocketAddress getAddress(GrpcRequest request) { SocketAddress address = request.getRemoteAddress(); if (address instanceof InetSocketAddress) { return (InetSocketAddress) address; 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/HttpUrlNetAttributesExtractor.java index e9e8cc73da72..939a0118fb32 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/HttpUrlNetAttributesExtractor.java @@ -17,17 +17,17 @@ class HttpUrlNetAttributesExtractor extends NetAttributesExtractor httpResponse) { + public @Nullable String peerName(HttpRequest httpRequest) { return httpRequest.uri().getHost(); } @Override - public @Nullable Integer peerPort( - HttpRequest httpRequest, @Nullable HttpResponse httpResponse) { + public @Nullable Integer peerPort(HttpRequest httpRequest) { int port = httpRequest.uri().getPort(); if (port != -1) { return port; @@ -52,7 +50,7 @@ public String transport(HttpRequest httpRequest) { } @Override - public @Nullable String peerIp(HttpRequest httpRequest, @Nullable HttpResponse httpResponse) { + public @Nullable String peerIp(HttpRequest httpRequest) { return null; } } 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/JaxRsClientNetAttributesExtractor.java index eb80e0166a7f..961eccb81dc3 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/JaxRsClientNetAttributesExtractor.java @@ -20,12 +20,12 @@ public String transport(ClientRequest request) { } @Override - public @Nullable String peerName(ClientRequest request, @Nullable ClientResponse response) { + public @Nullable String peerName(ClientRequest request) { return request.getURI().getHost(); } @Override - public Integer peerPort(ClientRequest request, @Nullable ClientResponse response) { + public Integer peerPort(ClientRequest request) { int port = request.getURI().getPort(); if (port != -1) { return port; @@ -34,7 +34,7 @@ public Integer peerPort(ClientRequest request, @Nullable ClientResponse response } @Override - public @Nullable String peerIp(ClientRequest request, @Nullable ClientResponse response) { + public @Nullable String peerIp(ClientRequest request) { return null; } } 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/JaxRsClientNetAttributesExtractor.java index de96a7087640..0a56b5e7f967 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/JaxRsClientNetAttributesExtractor.java @@ -20,13 +20,12 @@ public String transport(ClientRequestContext request) { } @Override - public @Nullable String peerName( - ClientRequestContext request, @Nullable ClientResponseContext response) { + public @Nullable String peerName(ClientRequestContext request) { return request.getUri().getHost(); } @Override - public Integer peerPort(ClientRequestContext request, @Nullable ClientResponseContext response) { + public Integer peerPort(ClientRequestContext request) { int port = request.getUri().getPort(); if (port != -1) { return port; @@ -35,8 +34,7 @@ public Integer peerPort(ClientRequestContext request, @Nullable ClientResponseCo } @Override - public @Nullable String peerIp( - ClientRequestContext request, @Nullable ClientResponseContext response) { + public @Nullable String peerIp(ClientRequestContext request) { return null; } } 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/ResteasyClientNetAttributesExtractor.java index 62c9115968b8..d6728f5d3483 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/ResteasyClientNetAttributesExtractor.java @@ -20,12 +20,12 @@ public String transport(ClientInvocation request) { } @Override - public @Nullable String peerName(ClientInvocation request, @Nullable Response response) { + public @Nullable String peerName(ClientInvocation request) { return request.getUri().getHost(); } @Override - public Integer peerPort(ClientInvocation request, @Nullable Response response) { + public Integer peerPort(ClientInvocation request) { int port = request.getUri().getPort(); if (port != -1) { return port; @@ -34,7 +34,7 @@ public Integer peerPort(ClientInvocation request, @Nullable Response response) { } @Override - public @Nullable String peerIp(ClientInvocation request, @Nullable Response response) { + public @Nullable String peerIp(ClientInvocation request) { return null; } } 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/JdbcNetAttributesExtractor.java index c0b9bd67525c..0028f423d824 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/JdbcNetAttributesExtractor.java @@ -18,19 +18,19 @@ public String transport(DbRequest request) { @Nullable @Override - public String peerName(DbRequest request, @Nullable Void unused) { + public String peerName(DbRequest request) { return request.getDbInfo().getHost(); } @Nullable @Override - public Integer peerPort(DbRequest request, @Nullable Void unused) { + public Integer peerPort(DbRequest request) { return request.getDbInfo().getPort(); } @Nullable @Override - public String peerIp(DbRequest request, @Nullable Void unused) { + public String peerIp(DbRequest request) { return null; } } 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/JedisNetAttributesExtractor.java index 0647d9dedc2c..9ef355d48885 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/JedisNetAttributesExtractor.java @@ -17,18 +17,18 @@ public String transport(JedisRequest request) { } @Override - public String peerName(JedisRequest request, @Nullable Void unused) { + public String peerName(JedisRequest request) { return request.getConnection().getHost(); } @Override - public Integer peerPort(JedisRequest request, @Nullable Void unused) { + public Integer peerPort(JedisRequest request) { return request.getConnection().getPort(); } @Override @Nullable - public String peerIp(JedisRequest request, @Nullable Void unused) { + public String peerIp(JedisRequest request) { return null; } } 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/JedisNetAttributesExtractor.java index 5927492ad0d7..f6c424d3207a 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/JedisNetAttributesExtractor.java @@ -15,7 +15,7 @@ final class JedisNetAttributesExtractor extends InetSocketAddressNetAttributesExtractor { @Override - public @Nullable InetSocketAddress getAddress(JedisRequest jedisRequest, @Nullable Void unused) { + public @Nullable InetSocketAddress getAddress(JedisRequest jedisRequest) { Socket socket = jedisRequest.getConnection().getSocket(); if (socket != null && socket.getRemoteSocketAddress() instanceof InetSocketAddress) { return (InetSocketAddress) socket.getRemoteSocketAddress(); 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/JettyHttpClientNetAttributesExtractor.java index 1cddd2826b95..d8b806a36879 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/JettyHttpClientNetAttributesExtractor.java @@ -21,19 +21,19 @@ public String transport(Request request) { @Override @Nullable - public String peerName(Request request, @Nullable Response response) { + public String peerName(Request request) { return request.getHost(); } @Override @Nullable - public Integer peerPort(Request request, @Nullable Response response) { + public Integer peerPort(Request request) { return request.getPort(); } @Override @Nullable - public String peerIp(Request request, @Nullable Response response) { + public String peerIp(Request request) { // Return null unless the library supports resolution to something similar to SocketAddress // https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/3012/files#r633188645 return null; 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/KubernetesNetAttributesExtractor.java index 185700820451..b5b4f5d2f0f6 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/KubernetesNetAttributesExtractor.java @@ -18,17 +18,17 @@ public String transport(Request request) { } @Override - public String peerName(Request request, @Nullable ApiResponse apiResponse) { + public String peerName(Request request) { return request.url().host(); } @Override - public Integer peerPort(Request request, @Nullable ApiResponse apiResponse) { + public Integer peerPort(Request request) { return request.url().port(); } @Override - public @Nullable String peerIp(Request request, @Nullable ApiResponse apiResponse) { + public @Nullable String peerIp(Request request) { return null; } } 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/LettuceConnectNetAttributesExtractor.java index d5731f9d5067..d85d784b2421 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/LettuceConnectNetAttributesExtractor.java @@ -18,18 +18,18 @@ public String transport(RedisURI redisUri) { } @Override - public String peerName(RedisURI redisUri, @Nullable Void unused) { + public String peerName(RedisURI redisUri) { return redisUri.getHost(); } @Override - public Integer peerPort(RedisURI redisUri, @Nullable Void unused) { + public Integer peerPort(RedisURI redisUri) { return redisUri.getPort(); } @Override @Nullable - public String peerIp(RedisURI redisUri, @Nullable Void unused) { + public String peerIp(RedisURI redisUri) { return null; } } 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/LettuceConnectNetAttributesExtractor.java index 6dcbbb3f359b..f98d289ede7c 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/LettuceConnectNetAttributesExtractor.java @@ -18,18 +18,18 @@ public String transport(RedisURI redisUri) { } @Override - public String peerName(RedisURI redisUri, @Nullable Void unused) { + public String peerName(RedisURI redisUri) { return redisUri.getHost(); } @Override - public Integer peerPort(RedisURI redisUri, @Nullable Void unused) { + public Integer peerPort(RedisURI redisUri) { return redisUri.getPort(); } @Override @Nullable - public String peerIp(RedisURI redisUri, @Nullable Void unused) { + public String peerIp(RedisURI redisUri) { return null; } } 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/OkHttp2NetAttributesExtractor.java index 311629264205..7a25a592f6b3 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/OkHttp2NetAttributesExtractor.java @@ -18,17 +18,17 @@ public String transport(Request request) { } @Override - public @Nullable String peerName(Request request, @Nullable Response response) { + public @Nullable String peerName(Request request) { return request.url().getHost(); } @Override - public Integer peerPort(Request request, @Nullable Response response) { + public Integer peerPort(Request request) { return request.url().getPort(); } @Override - public @Nullable String peerIp(Request request, @Nullable Response response) { + public @Nullable String peerIp(Request request) { return null; } } 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/OkHttpNetAttributesExtractor.java index 929ac8d79213..dad02f758ea8 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/OkHttpNetAttributesExtractor.java @@ -18,17 +18,17 @@ public String transport(Request request) { } @Override - public @Nullable String peerName(Request request, @Nullable Response response) { + public @Nullable String peerName(Request request) { return request.url().host(); } @Override - public Integer peerPort(Request request, @Nullable Response response) { + public Integer peerPort(Request request) { return request.url().port(); } @Override - public @Nullable String peerIp(Request request, @Nullable Response response) { + public @Nullable String peerIp(Request request) { return null; } } 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/PlayWsClientNetAttributesExtractor.java index 6c50ae237ced..3986a66795d4 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/PlayWsClientNetAttributesExtractor.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.playws; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetResponseAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; @@ -13,7 +13,7 @@ import play.shaded.ahc.org.asynchttpclient.Response; final class PlayWsClientNetAttributesExtractor - extends InetSocketAddressNetAttributesExtractor { + extends InetSocketAddressNetResponseAttributesExtractor { @Override public String transport(Request request) { 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 bcd95b3d2d7e..2445751b9305 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 @@ -13,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceResponseAttributesExtractor; import play.shaded.ahc.org.asynchttpclient.Request; import play.shaded.ahc.org.asynchttpclient.Response; @@ -38,7 +38,8 @@ public class PlayWsClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceResponseAttributesExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } diff --git a/instrumentation/ratpack-1.4/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesExtractor.java b/instrumentation/ratpack-1.4/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesExtractor.java index f43f19e01124..715c81ecf449 100644 --- a/instrumentation/ratpack-1.4/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesExtractor.java +++ b/instrumentation/ratpack-1.4/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesExtractor.java @@ -20,18 +20,18 @@ public String transport(Request request) { @Override @Nullable - public String peerName(Request request, @Nullable Response response) { + public String peerName(Request request) { return null; } @Override - public Integer peerPort(Request request, @Nullable Response response) { + public Integer peerPort(Request request) { return request.getRemoteAddress().getPort(); } @Override @Nullable - public String peerIp(Request request, @Nullable Response response) { + public String peerIp(Request request) { return null; } } 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/RedissonNetAttributesExtractor.java index 4faf9ade5fcc..9a70b271ab45 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/RedissonNetAttributesExtractor.java @@ -13,7 +13,7 @@ final class RedissonNetAttributesExtractor extends InetSocketAddressNetAttributesExtractor { @Override - public InetSocketAddress getAddress(RedissonRequest request, @Nullable Void unused) { + public InetSocketAddress getAddress(RedissonRequest request) { return request.getAddress(); } diff --git a/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesExtractor.java b/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesExtractor.java index cc4a6f1ff277..1df4dbb52d54 100644 --- a/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesExtractor.java +++ b/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesExtractor.java @@ -18,17 +18,17 @@ public String transport(Request request) { } @Override - public @Nullable String peerName(Request request, @Nullable Response response) { + public @Nullable String peerName(Request request) { return null; } @Override - public Integer peerPort(Request request, @Nullable Response response) { + public Integer peerPort(Request request) { return request.getClientInfo().getPort(); } @Override - public @Nullable String peerIp(Request request, @Nullable Response response) { + public @Nullable String peerIp(Request request) { return request.getClientInfo().getAddress(); } } diff --git a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesExtractor.java b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesExtractor.java index f5f03cf15b52..548cca6d3f9c 100644 --- a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesExtractor.java +++ b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesExtractor.java @@ -25,24 +25,18 @@ public ServletNetAttributesExtractor(ServletAccessor accessor } @Override - public @Nullable String peerName( - ServletRequestContext requestContext, - @Nullable ServletResponseContext responseContext) { + public @Nullable String peerName(ServletRequestContext requestContext) { // return accessor.getRequestRemoteHost(requestContext.request()); return null; } @Override - public @Nullable Integer peerPort( - ServletRequestContext requestContext, - @Nullable ServletResponseContext responseContext) { + public @Nullable Integer peerPort(ServletRequestContext requestContext) { return accessor.getRequestRemotePort(requestContext.request()); } @Override - public @Nullable String peerIp( - ServletRequestContext requestContext, - @Nullable ServletResponseContext responseContext) { + public @Nullable String peerIp(ServletRequestContext requestContext) { return accessor.getRequestRemoteAddr(requestContext.request()); } } diff --git a/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesExtractor.java b/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesExtractor.java index 09141a106c18..3b1a4ec93401 100644 --- a/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesExtractor.java +++ b/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesExtractor.java @@ -19,20 +19,17 @@ public String transport(HttpRequest httpRequest) { } @Override - public @Nullable String peerName( - HttpRequest httpRequest, @Nullable ClientHttpResponse clientHttpResponse) { + public @Nullable String peerName(HttpRequest httpRequest) { return httpRequest.getURI().getHost(); } @Override - public Integer peerPort( - HttpRequest httpRequest, @Nullable ClientHttpResponse clientHttpResponse) { + public Integer peerPort(HttpRequest httpRequest) { return httpRequest.getURI().getPort(); } @Override - public @Nullable String peerIp( - HttpRequest httpRequest, @Nullable ClientHttpResponse clientHttpResponse) { + public @Nullable String peerIp(HttpRequest httpRequest) { return null; } } diff --git a/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesExtractor.java b/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesExtractor.java index 5cc7c8bf0ba0..e32db1be7ddf 100644 --- a/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesExtractor.java +++ b/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesExtractor.java @@ -19,19 +19,17 @@ public String transport(HttpServletRequest request) { } @Override - public @Nullable String peerName( - HttpServletRequest request, @Nullable HttpServletResponse response) { + public @Nullable String peerName(HttpServletRequest request) { return request.getRemoteHost(); } @Override - public Integer peerPort(HttpServletRequest request, @Nullable HttpServletResponse response) { + public Integer peerPort(HttpServletRequest request) { return request.getRemotePort(); } @Override - public @Nullable String peerIp( - HttpServletRequest request, @Nullable HttpServletResponse response) { + public @Nullable String peerIp(HttpServletRequest request) { return request.getRemoteAddr(); } } diff --git a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesExtractor.java b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesExtractor.java index 4552f2d58284..dafa9b67cc38 100644 --- a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesExtractor.java +++ b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesExtractor.java @@ -20,7 +20,7 @@ public class TomcatNetAttributesExtractor extends NetAttributesExtractor { @Override - public @Nullable InetSocketAddress getAddress( - HttpServerExchange exchange, @Nullable HttpServerExchange unused) { + public @Nullable InetSocketAddress getAddress(HttpServerExchange exchange) { return exchange.getConnection().getPeerAddress(InetSocketAddress.class); } diff --git a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java index 07503798eddb..f41da98e74fb 100644 --- a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java +++ b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java @@ -50,19 +50,10 @@ public static PeerServiceAttributesExtractorthe + * specification. + * + *

Peer service name mappings can be configured using the {@code + * otel.instrumentation.common.peer-service-mapping} configuration property. The format used is a + * comma-separated list of {@code host=name} pairs. + */ +public final class PeerServiceResponseAttributesExtractor + extends AttributesExtractor { + private static final Map JAVAAGENT_PEER_SERVICE_MAPPING = + Config.get().getMap("otel.instrumentation.common.peer-service-mapping"); + + private final Map peerServiceMapping; + private final NetResponseAttributesExtractor netResponseAttributesExtractor; + + // visible for tests + PeerServiceResponseAttributesExtractor( + Map peerServiceMapping, + NetResponseAttributesExtractor netResponseAttributesExtractor) { + this.peerServiceMapping = peerServiceMapping; + this.netResponseAttributesExtractor = netResponseAttributesExtractor; + } + + /** + * Returns a new {@link PeerServiceResponseAttributesExtractor} that will use the passed {@code + * netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute. + */ + public static + PeerServiceResponseAttributesExtractor create( + NetResponseAttributesExtractor netResponseAttributesExtractor) { + return new PeerServiceResponseAttributesExtractor<>( + JAVAAGENT_PEER_SERVICE_MAPPING, netResponseAttributesExtractor); + } + + @Override + protected void onStart(AttributesBuilder attributes, REQUEST request) { + onEnd(attributes, request, null, null); + } + + @Override + protected void onEnd( + AttributesBuilder attributes, + REQUEST request, + @Nullable RESPONSE response, + @Nullable Throwable error) { + String peerName = netResponseAttributesExtractor.peerName(request, response); + String peerService = mapToPeerService(peerName); + if (peerService == null) { + String peerIp = netResponseAttributesExtractor.peerIp(request, response); + peerService = mapToPeerService(peerIp); + } + if (peerService != null) { + attributes.put(SemanticAttributes.PEER_SERVICE, peerService); + } + } + + private String mapToPeerService(String endpoint) { + if (endpoint == null) { + return null; + } + return peerServiceMapping.get(endpoint); + } +} From 0285c1b5df8aa7c2a4f821ce1c0063d1838357c5 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 3 Oct 2021 11:24:54 -0700 Subject: [PATCH 02/26] Either request or response but not both --- ...AddressNetResponseAttributesExtractor.java | 14 ++++++------ .../net/NetResponseAttributesExtractor.java | 22 +++++++++---------- .../api/instrumenter/InstrumenterTest.java | 8 +++---- .../net/NetAttributesExtractorTest.java | 16 +++++++------- ...AsyncHttpClientNetAttributesExtractor.java | 5 ++--- .../v3_0/CassandraNetAttributesExtractor.java | 5 ++--- .../v4_0/CassandraNetAttributesExtractor.java | 5 ++--- ...rchRestNetResponseAttributesExtractor.java | 8 +++---- ...earch6TransportNetAttributesExtractor.java | 5 ++--- ...ansportNetResponseAttributesExtractor.java | 11 ++++------ .../PlayWsClientNetAttributesExtractor.java | 4 ++-- ...eerServiceResponseAttributesExtractor.java | 4 ++-- 12 files changed, 50 insertions(+), 57 deletions(-) diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetResponseAttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetResponseAttributesExtractor.java index a241d43a3716..d28a1e125e79 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetResponseAttributesExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetResponseAttributesExtractor.java @@ -26,12 +26,12 @@ public abstract class InetSocketAddressNetResponseAttributesExtractorNetwork * attributes. It is common to have access to {@link java.net.InetSocketAddress}, in which case - * it is more convenient to use {@link InetSocketAddressNetAttributesExtractor}. + * it is more convenient to use {@link InetSocketAddressNetResponseAttributesExtractor}. */ public abstract class NetResponseAttributesExtractor extends AttributesExtractor { @Override - protected final void onStart(AttributesBuilder attributes, REQUEST request) { - set(attributes, SemanticAttributes.NET_TRANSPORT, transport(request)); - } + protected final void onStart(AttributesBuilder attributes, REQUEST request) {} @Override protected final void onEnd( @@ -31,22 +29,24 @@ protected final void onEnd( @Nullable RESPONSE response, @Nullable Throwable error) { - String peerIp = peerIp(request, response); - String peerName = peerName(request, response); + set(attributes, SemanticAttributes.NET_TRANSPORT, transport(response)); + + String peerIp = peerIp(response); + String peerName = peerName(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 = peerPort(response); if (peerPort != null) { set(attributes, SemanticAttributes.NET_PEER_PORT, (long) peerPort); } } @Nullable - public abstract String transport(REQUEST request); + public abstract String transport(@Nullable RESPONSE response); /** * This method will be called twice: both when the request starts ({@code response} is always null @@ -54,7 +54,7 @@ protected final void onEnd( * phases of processing. */ @Nullable - public abstract String peerName(REQUEST request, @Nullable RESPONSE response); + public abstract String peerName(@Nullable RESPONSE response); /** * This method will be called twice: both when the request starts ({@code response} is always null @@ -62,7 +62,7 @@ protected final void onEnd( * phases of processing. */ @Nullable - public abstract Integer peerPort(REQUEST request, @Nullable RESPONSE response); + public abstract Integer peerPort(@Nullable RESPONSE response); /** * This method will be called twice: both when the request starts ({@code response} is always null @@ -70,5 +70,5 @@ protected final void onEnd( * phases of processing. */ @Nullable - public abstract String peerIp(REQUEST request, @Nullable RESPONSE response); + public abstract String peerIp(@Nullable RESPONSE response); } diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterTest.java index 7a4aae4cf103..86c8ac05d3ff 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterTest.java @@ -279,8 +279,8 @@ void server_http() { .addSpanLinksExtractor(new LinksExtractor()) .newServerInstrumenter(new MapGetter()); - when(mockNetAttributes.peerIp(REQUEST, null)).thenReturn("2.2.2.2"); - when(mockNetAttributes.peerIp(REQUEST, RESPONSE)).thenReturn("2.2.2.2"); + when(mockNetAttributes.peerIp(REQUEST)).thenReturn("2.2.2.2"); + when(mockNetAttributes.peerIp(REQUEST)).thenReturn("2.2.2.2"); Context context = instrumenter.start(Context.root(), REQUEST); SpanContext spanContext = Span.fromContext(context).getSpanContext(); @@ -322,8 +322,8 @@ void server_http_xForwardedFor() { request.remove("Forwarded"); request.put("X-Forwarded-For", "1.1.1.1"); - when(mockNetAttributes.peerIp(request, null)).thenReturn("2.2.2.2"); - when(mockNetAttributes.peerIp(request, RESPONSE)).thenReturn("2.2.2.2"); + when(mockNetAttributes.peerIp(request)).thenReturn("2.2.2.2"); + when(mockNetAttributes.peerIp(request)).thenReturn("2.2.2.2"); Context context = instrumenter.start(Context.root(), request); SpanContext spanContext = Span.fromContext(context).getSpanContext(); diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesExtractorTest.java index bcd300945e62..8cb517ed7381 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesExtractorTest.java @@ -45,32 +45,32 @@ static class TestNetResponseAttributesExtractor extends NetResponseAttributesExtractor, Map> { @Override - public String transport(Map request) { - return request.get("transport"); + public String transport(Map response) { + return response.get("transport"); } @Override - public String peerName(Map request, Map response) { + public String peerName(Map response) { if (response != null) { return response.get("peerName"); } - return request.get("peerName"); + return null; } @Override - public Integer peerPort(Map request, Map response) { + public Integer peerPort(Map response) { if (response != null) { return Integer.valueOf(response.get("peerPort")); } - return Integer.valueOf(request.get("peerPort")); + return null; } @Override - public String peerIp(Map request, Map response) { + public String peerIp(Map response) { if (response != null) { return response.get("peerIp"); } - return request.get("peerIp"); + return null; } } 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/AsyncHttpClientNetAttributesExtractor.java index 7ba54f2c481f..53479ef0c01f 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/AsyncHttpClientNetAttributesExtractor.java @@ -15,13 +15,12 @@ final class AsyncHttpClientNetAttributesExtractor extends InetSocketAddressNetResponseAttributesExtractor { @Override - public String transport(RequestContext requestContext) { + public String transport(@Nullable Response response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public @Nullable InetSocketAddress getAddress( - RequestContext requestContext, @Nullable Response response) { + public @Nullable InetSocketAddress getAddress(@Nullable Response response) { if (response != null && response.getRemoteAddress() instanceof InetSocketAddress) { return (InetSocketAddress) response.getRemoteAddress(); } 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/CassandraNetAttributesExtractor.java index 456c8f451197..7ed7b9949e4a 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/CassandraNetAttributesExtractor.java @@ -15,13 +15,12 @@ final class CassandraNetAttributesExtractor @Override @Nullable - public String transport(CassandraRequest request) { + public String transport(@Nullable ExecutionInfo executionInfo) { return null; } @Override - public @Nullable InetSocketAddress getAddress( - CassandraRequest request, @Nullable ExecutionInfo executionInfo) { + public @Nullable InetSocketAddress getAddress(@Nullable ExecutionInfo executionInfo) { return executionInfo == null ? null : executionInfo.getQueriedHost().getSocketAddress(); } } 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/CassandraNetAttributesExtractor.java index 24b45be65328..b919fd669331 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/CassandraNetAttributesExtractor.java @@ -17,13 +17,12 @@ final class CassandraNetAttributesExtractor @Override @Nullable - public String transport(CassandraRequest request) { + public String transport(@Nullable ExecutionInfo executionInfo) { return null; } @Override - public @Nullable InetSocketAddress getAddress( - CassandraRequest request, @Nullable ExecutionInfo executionInfo) { + public @Nullable InetSocketAddress getAddress(@Nullable ExecutionInfo executionInfo) { if (executionInfo == null) { return null; } 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/ElasticsearchRestNetResponseAttributesExtractor.java index e3ae6b07dbf2..10ffaa8da950 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/ElasticsearchRestNetResponseAttributesExtractor.java @@ -13,12 +13,12 @@ final class ElasticsearchRestNetResponseAttributesExtractor extends NetResponseAttributesExtractor { @Override - public String transport(String s) { + public String transport(Response response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public @Nullable String peerName(String s, @Nullable Response response) { + public @Nullable String peerName(@Nullable Response response) { if (response != null) { return response.getHost().getHostName(); } @@ -26,7 +26,7 @@ public String transport(String s) { } @Override - public @Nullable Integer peerPort(String s, @Nullable Response response) { + public @Nullable Integer peerPort(@Nullable Response response) { if (response != null) { return response.getHost().getPort(); } @@ -34,7 +34,7 @@ public String transport(String s) { } @Override - public @Nullable String peerIp(String s, @Nullable Response response) { + public @Nullable String peerIp(@Nullable Response response) { if (response != null && response.getHost().getAddress() != null) { return response.getHost().getAddress().getHostAddress(); } 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/Elasticsearch6TransportNetAttributesExtractor.java index 6f87c729dbfa..e652aae0f337 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/Elasticsearch6TransportNetAttributesExtractor.java @@ -15,13 +15,12 @@ public class Elasticsearch6TransportNetAttributesExtractor extends InetSocketAddressNetResponseAttributesExtractor< ElasticTransportRequest, ActionResponse> { @Override - public @Nullable String transport(ElasticTransportRequest elasticTransportRequest) { + public @Nullable String transport(@Nullable ActionResponse response) { return null; } @Override - public @Nullable InetSocketAddress getAddress( - ElasticTransportRequest elasticTransportRequest, @Nullable ActionResponse response) { + public @Nullable InetSocketAddress getAddress(@Nullable ActionResponse response) { if (response != null && response.remoteAddress() != null) { return response.remoteAddress().address(); } 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/ElasticTransportNetResponseAttributesExtractor.java index cb46911a58d2..6e867c19b441 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/ElasticTransportNetResponseAttributesExtractor.java @@ -12,13 +12,12 @@ public class ElasticTransportNetResponseAttributesExtractor extends NetResponseAttributesExtractor { @Override - public @Nullable String transport(ElasticTransportRequest elasticTransportRequest) { + public @Nullable String transport(@Nullable ActionResponse response) { return null; } @Override - public @Nullable String peerName( - ElasticTransportRequest elasticTransportRequest, @Nullable ActionResponse response) { + public @Nullable String peerName(@Nullable ActionResponse response) { if (response != null && response.remoteAddress() != null) { return response.remoteAddress().getHost(); } @@ -26,8 +25,7 @@ public class ElasticTransportNetResponseAttributesExtractor } @Override - public @Nullable Integer peerPort( - ElasticTransportRequest elasticTransportRequest, @Nullable ActionResponse response) { + public @Nullable Integer peerPort(@Nullable ActionResponse response) { if (response != null && response.remoteAddress() != null) { return response.remoteAddress().getPort(); } @@ -35,8 +33,7 @@ public class ElasticTransportNetResponseAttributesExtractor } @Override - public @Nullable String peerIp( - ElasticTransportRequest elasticTransportRequest, @Nullable ActionResponse response) { + public @Nullable String peerIp(@Nullable ActionResponse response) { if (response != null && response.remoteAddress() != null) { return response.remoteAddress().getAddress(); } 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/PlayWsClientNetAttributesExtractor.java index 3986a66795d4..2a6b12b863dd 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/PlayWsClientNetAttributesExtractor.java @@ -16,12 +16,12 @@ final class PlayWsClientNetAttributesExtractor extends InetSocketAddressNetResponseAttributesExtractor { @Override - public String transport(Request request) { + public String transport(@Nullable Response response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public @Nullable InetSocketAddress getAddress(Request request, @Nullable Response response) { + public @Nullable InetSocketAddress getAddress(@Nullable Response response) { if (response != null && response.getRemoteAddress() instanceof InetSocketAddress) { return (InetSocketAddress) response.getRemoteAddress(); } diff --git a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceResponseAttributesExtractor.java b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceResponseAttributesExtractor.java index ad6bd223c358..ed52e909f1d5 100644 --- a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceResponseAttributesExtractor.java +++ b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceResponseAttributesExtractor.java @@ -60,10 +60,10 @@ protected void onEnd( REQUEST request, @Nullable RESPONSE response, @Nullable Throwable error) { - String peerName = netResponseAttributesExtractor.peerName(request, response); + String peerName = netResponseAttributesExtractor.peerName(response); String peerService = mapToPeerService(peerName); if (peerService == null) { - String peerIp = netResponseAttributesExtractor.peerIp(request, response); + String peerIp = netResponseAttributesExtractor.peerIp(response); peerService = mapToPeerService(peerIp); } if (peerService != null) { From 153189f45b7be76f2fa1815ace82712cff37bbf5 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 3 Oct 2021 11:44:07 -0700 Subject: [PATCH 03/26] Fix merge conflicts --- .../LibertyDispatcherLinkInstrumentation.java | 1 - ...bertyDispatcherNetAttributesExtractor.java | 27 +++++-------------- .../liberty/dispatcher/LibertyRequest.java | 9 ------- 3 files changed, 6 insertions(+), 31 deletions(-) diff --git a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherLinkInstrumentation.java b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherLinkInstrumentation.java index acf7d195372c..abdea866ec43 100644 --- a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherLinkInstrumentation.java +++ b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherLinkInstrumentation.java @@ -80,7 +80,6 @@ public static void stopSpan( scope.close(); LibertyResponse response = new LibertyResponse(statusCode); - request.setCompleted(); Throwable t = failure != null ? failure : throwable; instrumenter().end(context, request, response, t); diff --git a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesExtractor.java b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesExtractor.java index a92444eabe39..90ceca6a25ee 100644 --- a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesExtractor.java +++ b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesExtractor.java @@ -18,32 +18,17 @@ public String transport(LibertyRequest libertyRequest) { } @Override - public @Nullable String peerName( - LibertyRequest libertyRequest, @Nullable LibertyResponse libertyResponse) { - // condition limits calling peerName to onStart because in onEnd it may throw a NPE - if (!libertyRequest.isCompleted()) { - return libertyRequest.peerName(); - } - return null; + public @Nullable String peerName(LibertyRequest libertyRequest) { + return libertyRequest.peerName(); } @Override - public @Nullable Integer peerPort( - LibertyRequest libertyRequest, @Nullable LibertyResponse libertyResponse) { - // condition limits calling getServerPort to onStart because in onEnd it may throw a NPE - if (!libertyRequest.isCompleted()) { - return libertyRequest.getServerPort(); - } - return null; + public @Nullable Integer peerPort(LibertyRequest libertyRequest) { + return libertyRequest.getServerPort(); } @Override - public @Nullable String peerIp( - LibertyRequest libertyRequest, @Nullable LibertyResponse libertyResponse) { - // condition limits calling peerIp to onStart because in onEnd it may throw a NPE - if (!libertyRequest.isCompleted()) { - return libertyRequest.peerIp(); - } - return null; + public @Nullable String peerIp(LibertyRequest libertyRequest) { + return libertyRequest.peerIp(); } } diff --git a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyRequest.java b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyRequest.java index 549173c7b4e6..b8ffed84ffa0 100644 --- a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyRequest.java +++ b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyRequest.java @@ -13,7 +13,6 @@ public class LibertyRequest { private final HttpDispatcherLink httpDispatcherLink; private final HttpRequestMessage httpRequestMessage; - private boolean completed; public LibertyRequest( HttpDispatcherLink httpDispatcherLink, HttpRequestMessage httpRequestMessage) { @@ -69,12 +68,4 @@ public String peerName() { public String getProtocol() { return httpRequestMessage.getVersion(); } - - public boolean isCompleted() { - return completed; - } - - public void setCompleted() { - completed = true; - } } From d8cde527c43d3f552a90744d5fe5b4902c49d6ef Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Mon, 4 Oct 2021 12:17:19 -0700 Subject: [PATCH 04/26] Separate by OnStart/OnEnd --- .../benchmark/InstrumenterBenchmark.java | 4 +- .../api/instrumenter/AttributesExtractor.java | 4 +- ...etAddressNetAttributesOnEndExtractor.java} | 21 +-- ...AddressNetAttributesOnStartExtractor.java} | 9 +- ....java => NetAttributesOnEndExtractor.java} | 35 +--- ...ava => NetAttributesOnStartExtractor.java} | 4 +- .../api/instrumenter/InstrumenterTest.java | 4 +- ...dressNetAttributesOnEndExtractorTest.java} | 32 +--- ...ressNetAttributesOnStartExtractorTest.java | 82 +++++++++ .../net/NetAttributesExtractorTest.java | 174 ------------------ .../net/NetAttributesOnEndExtractorTest.java | 107 +++++++++++ .../NetAttributesOnStartExtractorTest.java | 90 +++++++++ .../internal/DubboNetAttributesExtractor.java | 4 +- ...HttpAsyncClientNetAttributesExtractor.java | 4 +- ...pacheHttpClientNetAttributesExtractor.java | 4 +- ...pacheHttpClientNetAttributesExtractor.java | 4 +- ...pacheHttpClientNetAttributesExtractor.java | 4 +- ...pacheHttpClientNetAttributesExtractor.java | 4 +- .../ArmeriaNetAttributesExtractor.java | 4 +- ...AsyncHttpClientNetAttributesExtractor.java | 4 +- ...AsyncHttpClientNetAttributesExtractor.java | 9 +- .../v2_0/AsyncHttpClientSingletons.java | 4 +- .../v3_0/CassandraNetAttributesExtractor.java | 9 +- .../v4_0/CassandraNetAttributesExtractor.java | 9 +- .../ElasticsearchRestAttributesExtractor.java | 10 +- ...rchRestNetResponseAttributesExtractor.java | 12 +- ...earch6TransportNetAttributesExtractor.java | 11 +- ...ansportNetResponseAttributesExtractor.java | 16 +- ...oogleHttpClientNetAttributesExtractor.java | 4 +- .../internal/GrpcNetAttributesExtractor.java | 4 +- .../HttpUrlNetAttributesExtractor.java | 5 +- .../JdkHttpNetAttributesExtractor.java | 4 +- .../JaxRsClientNetAttributesExtractor.java | 4 +- .../JaxRsClientNetAttributesExtractor.java | 4 +- .../ResteasyClientNetAttributesExtractor.java | 4 +- .../internal/JdbcNetAttributesExtractor.java | 5 +- .../v1_4/JedisNetAttributesExtractor.java | 4 +- .../v3_0/JedisNetAttributesExtractor.java | 4 +- ...JettyHttpClientNetAttributesExtractor.java | 4 +- .../KubernetesNetAttributesExtractor.java | 5 +- .../LettuceConnectNetAttributesExtractor.java | 5 +- .../LettuceConnectNetAttributesExtractor.java | 5 +- ...bertyDispatcherNetAttributesExtractor.java | 4 +- .../LibertyDispatcherSingletons.java | 4 +- .../v2_2/OkHttp2NetAttributesExtractor.java | 5 +- .../okhttp/v2_2/OkHttp2Singletons.java | 4 +- .../OkHttpNetAttributesExtractor.java | 5 +- .../PlayWsClientNetAttributesExtractor.java | 8 +- .../RatpackNetAttributesExtractor.java | 5 +- .../RedissonNetAttributesExtractor.java | 4 +- .../v1_0/RestletNetAttributesExtractor.java | 4 +- .../restlet/v1_0/RestletTracingBuilder.java | 4 +- .../ServletNetAttributesExtractor.java | 4 +- .../web/SpringWebNetAttributesExtractor.java | 4 +- .../SpringWebMvcNetAttributesExtractor.java | 4 +- .../common/TomcatInstrumenterBuilder.java | 4 +- .../common/TomcatNetAttributesExtractor.java | 4 +- .../UndertowNetAttributesExtractor.java | 4 +- .../undertow/UndertowSingletons.java | 4 +- .../PeerServiceAttributesExtractor.java | 8 +- ...eerServiceResponseAttributesExtractor.java | 8 +- .../PeerServiceAttributesExtractorTest.java | 4 +- 62 files changed, 461 insertions(+), 373 deletions(-) rename instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/{InetSocketAddressNetResponseAttributesExtractor.java => InetSocketAddressNetAttributesOnEndExtractor.java} (66%) rename instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/{InetSocketAddressNetAttributesExtractor.java => InetSocketAddressNetAttributesOnStartExtractor.java} (87%) rename instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/{NetResponseAttributesExtractor.java => NetAttributesOnEndExtractor.java} (53%) rename instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/{NetAttributesExtractor.java => NetAttributesOnStartExtractor.java} (96%) rename instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/{InetSocketAddressNetAttributesExtractorTest.java => InetSocketAddressNetAttributesOnEndExtractorTest.java} (69%) create mode 100644 instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnStartExtractorTest.java delete mode 100644 instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesExtractorTest.java create mode 100644 instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnEndExtractorTest.java create mode 100644 instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnStartExtractorTest.java diff --git a/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java b/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java index e0de56a3757d..0f1db4e73011 100644 --- a/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java +++ b/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java @@ -10,7 +10,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; @@ -105,7 +105,7 @@ static class ConstantHttpAttributesExtractor extends HttpClientAttributesExtract } static class ConstantNetAttributesExtractor - extends InetSocketAddressNetAttributesExtractor { + extends InetSocketAddressNetAttributesOnStartExtractor { private static final InetSocketAddress ADDRESS = InetSocketAddress.createUnresolved("localhost", 8080); diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java index 6b7c666e5d9f..d5cec3455118 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java @@ -9,7 +9,7 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.instrumentation.api.instrumenter.db.DbAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import org.checkerframework.checker.nullness.qual.Nullable; /** @@ -22,7 +22,7 @@ * * @see DbAttributesExtractor * @see HttpClientAttributesExtractor - * @see NetAttributesExtractor + * @see NetAttributesOnStartExtractor */ public abstract class AttributesExtractor { /** diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetResponseAttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnEndExtractor.java similarity index 66% rename from instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetResponseAttributesExtractor.java rename to instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnEndExtractor.java index d28a1e125e79..8bfa618987e0 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetResponseAttributesExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnEndExtractor.java @@ -14,11 +14,10 @@ * href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/span-general.md#general-network-connection-attributes">Network * attributes from a {@link InetSocketAddress}. Most network libraries will provide access to a * {@link InetSocketAddress} so this is a convenient alternative to {@link - * NetResponseAttributesExtractor}. There is no meaning to implement both in the same - * instrumentation. + * NetAttributesOnEndExtractor}. There is no meaning to implement both in the same instrumentation. */ -public abstract class InetSocketAddressNetResponseAttributesExtractor - extends NetResponseAttributesExtractor { +public abstract class InetSocketAddressNetAttributesOnEndExtractor + extends NetAttributesOnEndExtractor { /** * This method will be called twice: both when the request starts ({@code response} is always null @@ -26,12 +25,12 @@ public abstract class InetSocketAddressNetResponseAttributesExtractorNetwork * attributes from a {@link InetSocketAddress}. Most network libraries will provide access to a - * {@link InetSocketAddress} so this is a convenient alternative to {@link NetAttributesExtractor}. - * There is no meaning to implement both in the same instrumentation. + * {@link InetSocketAddress} so this is a convenient alternative to {@link + * NetAttributesOnStartExtractor}. There is no meaning to implement both in the same + * instrumentation. */ -public abstract class InetSocketAddressNetAttributesExtractor - extends NetAttributesExtractor { +public abstract class InetSocketAddressNetAttributesOnStartExtractor + extends NetAttributesOnStartExtractor { /** * This method will be called twice: both when the request starts ({@code response} is always null diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetResponseAttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnEndExtractor.java similarity index 53% rename from instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetResponseAttributesExtractor.java rename to instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnEndExtractor.java index e59d06bc6c1b..31c9ae2acb65 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetResponseAttributesExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnEndExtractor.java @@ -14,9 +14,9 @@ * 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 InetSocketAddressNetResponseAttributesExtractor}. + * it is more convenient to use {@link InetSocketAddressNetAttributesOnEndExtractor}. */ -public abstract class NetResponseAttributesExtractor +public abstract class NetAttributesOnEndExtractor extends AttributesExtractor { @Override @@ -29,46 +29,31 @@ protected final void onEnd( @Nullable RESPONSE response, @Nullable Throwable error) { - set(attributes, SemanticAttributes.NET_TRANSPORT, transport(response)); + set(attributes, SemanticAttributes.NET_TRANSPORT, transport(request, response)); - String peerIp = peerIp(response); - String peerName = peerName(response); + String peerIp = peerIp(request, response); + String peerName = 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(response); + Integer peerPort = peerPort(request, response); if (peerPort != null) { set(attributes, SemanticAttributes.NET_PEER_PORT, (long) peerPort); } } @Nullable - public abstract String transport(@Nullable RESPONSE response); + public abstract String transport(REQUEST request, @Nullable RESPONSE response); - /** - * This method will be called twice: both when the request starts ({@code response} is always null - * then) and when the response ends. This way it is possible to capture net attributes in both - * phases of processing. - */ @Nullable - public abstract String peerName(@Nullable RESPONSE response); + public abstract String peerName(REQUEST request, @Nullable RESPONSE response); - /** - * This method will be called twice: both when the request starts ({@code response} is always null - * then) and when the response ends. This way it is possible to capture net attributes in both - * phases of processing. - */ @Nullable - public abstract Integer peerPort(@Nullable RESPONSE response); + public abstract Integer peerPort(REQUEST request, @Nullable RESPONSE response); - /** - * This method will be called twice: both when the request starts ({@code response} is always null - * then) and when the response ends. This way it is possible to capture net attributes in both - * phases of processing. - */ @Nullable - public abstract String peerIp(@Nullable RESPONSE response); + public abstract String peerIp(REQUEST request, @Nullable RESPONSE response); } diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnStartExtractor.java similarity index 96% rename from instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesExtractor.java rename to instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnStartExtractor.java index ff8537a27d29..136a94ae7bec 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnStartExtractor.java @@ -14,9 +14,9 @@ * 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 InetSocketAddressNetAttributesExtractor}. + * it is more convenient to use {@link InetSocketAddressNetAttributesOnStartExtractor}. */ -public abstract class NetAttributesExtractor +public abstract class NetAttributesOnStartExtractor extends AttributesExtractor { @Override diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterTest.java index 86c8ac05d3ff..c41a2245e047 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterTest.java @@ -27,7 +27,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.messaging.MessageOperation; import io.opentelemetry.instrumentation.api.instrumenter.messaging.MessagingAttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.instrumentation.api.instrumenter.rpc.RpcAttributesExtractor; import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; import io.opentelemetry.sdk.testing.junit5.OpenTelemetryExtension; @@ -155,7 +155,7 @@ public String get(Map carrier, String key) { MessagingAttributesExtractor, Map> mockMessagingAttributes; @Mock RpcAttributesExtractor, Map> mockRpcAttributes; - @Mock NetAttributesExtractor, Map> mockNetAttributes; + @Mock NetAttributesOnStartExtractor, Map> mockNetAttributes; @Test void server() { diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnEndExtractorTest.java similarity index 69% rename from instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesExtractorTest.java rename to instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnEndExtractorTest.java index 407273e0a27d..6750b5c345a5 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnEndExtractorTest.java @@ -17,19 +17,19 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class InetSocketAddressNetAttributesExtractorTest { +class InetSocketAddressNetAttributesOnEndExtractorTest { - private final InetSocketAddressNetAttributesExtractor + private final InetSocketAddressNetAttributesOnEndExtractor extractor = - new InetSocketAddressNetAttributesExtractor() { + new InetSocketAddressNetAttributesOnEndExtractor() { @Override public InetSocketAddress getAddress( InetSocketAddress request, InetSocketAddress response) { - return response != null ? response : request; + return response; } @Override - public String transport(InetSocketAddress inetSocketAddress) { + public String transport(InetSocketAddress request, InetSocketAddress response) { return SemanticAttributes.NetTransportValues.IP_TCP; } }; @@ -37,7 +37,6 @@ public String transport(InetSocketAddress inetSocketAddress) { @Test void noInetSocketAddress() { AttributesBuilder attributes = Attributes.builder(); - extractor.onStart(attributes, null); extractor.onEnd(attributes, null, null, null); assertThat(attributes.build()) .containsOnly( @@ -51,22 +50,13 @@ void fullAddress() { assertThat(address.getAddress().getHostAddress()).isNotNull(); // when - AttributesBuilder startAttributes = Attributes.builder(); - extractor.onStart(startAttributes, address); - AttributesBuilder endAttributes = Attributes.builder(); extractor.onEnd(endAttributes, null, address, null); // then - assertThat(startAttributes.build()) - .containsOnly( - entry(SemanticAttributes.NET_TRANSPORT, SemanticAttributes.NetTransportValues.IP_TCP), - entry(SemanticAttributes.NET_PEER_IP, address.getAddress().getHostAddress()), - entry(SemanticAttributes.NET_PEER_NAME, "github.com"), - entry(SemanticAttributes.NET_PEER_PORT, 123L)); - assertThat(endAttributes.build()) .containsOnly( + entry(SemanticAttributes.NET_TRANSPORT, SemanticAttributes.NetTransportValues.IP_TCP), entry(SemanticAttributes.NET_PEER_IP, address.getAddress().getHostAddress()), entry(SemanticAttributes.NET_PEER_NAME, "github.com"), entry(SemanticAttributes.NET_PEER_PORT, 123L)); @@ -79,21 +69,13 @@ void unresolved() { assertThat(address.getAddress()).isNull(); // when - AttributesBuilder startAttributes = Attributes.builder(); - extractor.onStart(startAttributes, address); - AttributesBuilder endAttributes = Attributes.builder(); extractor.onEnd(endAttributes, null, address, null); // then - assertThat(startAttributes.build()) - .containsOnly( - entry(SemanticAttributes.NET_TRANSPORT, SemanticAttributes.NetTransportValues.IP_TCP), - entry(SemanticAttributes.NET_PEER_NAME, "github.com"), - entry(SemanticAttributes.NET_PEER_PORT, 123L)); - assertThat(endAttributes.build()) .containsOnly( + entry(SemanticAttributes.NET_TRANSPORT, SemanticAttributes.NetTransportValues.IP_TCP), entry(SemanticAttributes.NET_PEER_NAME, "github.com"), entry(SemanticAttributes.NET_PEER_PORT, 123L)); } diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnStartExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnStartExtractorTest.java new file mode 100644 index 000000000000..22d5206783b8 --- /dev/null +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnStartExtractorTest.java @@ -0,0 +1,82 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.api.instrumenter.net; + +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; +import static org.assertj.core.api.Assertions.entry; + +import io.opentelemetry.api.common.Attributes; +import io.opentelemetry.api.common.AttributesBuilder; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; +import java.net.InetSocketAddress; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class InetSocketAddressNetAttributesOnStartExtractorTest { + + private final InetSocketAddressNetAttributesOnStartExtractor + extractor = + new InetSocketAddressNetAttributesOnStartExtractor< + InetSocketAddress, InetSocketAddress>() { + @Override + public InetSocketAddress getAddress(InetSocketAddress request) { + return request; + } + + @Override + public String transport(InetSocketAddress request) { + return SemanticAttributes.NetTransportValues.IP_TCP; + } + }; + + @Test + void noInetSocketAddress() { + AttributesBuilder attributes = Attributes.builder(); + extractor.onStart(attributes, null); + assertThat(attributes.build()) + .containsOnly( + entry(SemanticAttributes.NET_TRANSPORT, SemanticAttributes.NetTransportValues.IP_TCP)); + } + + @Test + void fullAddress() { + // given + InetSocketAddress address = new InetSocketAddress("github.com", 123); + assertThat(address.getAddress().getHostAddress()).isNotNull(); + + // when + AttributesBuilder startAttributes = Attributes.builder(); + extractor.onStart(startAttributes, address); + + // then + assertThat(startAttributes.build()) + .containsOnly( + entry(SemanticAttributes.NET_TRANSPORT, SemanticAttributes.NetTransportValues.IP_TCP), + entry(SemanticAttributes.NET_PEER_IP, address.getAddress().getHostAddress()), + entry(SemanticAttributes.NET_PEER_NAME, "github.com"), + entry(SemanticAttributes.NET_PEER_PORT, 123L)); + } + + @Test + void unresolved() { + // given + InetSocketAddress address = InetSocketAddress.createUnresolved("github.com", 123); + assertThat(address.getAddress()).isNull(); + + // when + AttributesBuilder startAttributes = Attributes.builder(); + extractor.onStart(startAttributes, address); + + // then + assertThat(startAttributes.build()) + .containsOnly( + entry(SemanticAttributes.NET_TRANSPORT, SemanticAttributes.NetTransportValues.IP_TCP), + entry(SemanticAttributes.NET_PEER_NAME, "github.com"), + entry(SemanticAttributes.NET_PEER_PORT, 123L)); + } +} diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesExtractorTest.java deleted file mode 100644 index 8cb517ed7381..000000000000 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesExtractorTest.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.instrumentation.api.instrumenter.net; - -import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; -import static org.assertj.core.api.Assertions.entry; - -import io.opentelemetry.api.common.Attributes; -import io.opentelemetry.api.common.AttributesBuilder; -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -class NetAttributesExtractorTest { - - static class TestNetAttributesExtractor - extends NetAttributesExtractor, Map> { - - @Override - public String transport(Map request) { - return request.get("transport"); - } - - @Override - public String peerName(Map request) { - return request.get("peerName"); - } - - @Override - public Integer peerPort(Map request) { - return Integer.valueOf(request.get("peerPort")); - } - - @Override - public String peerIp(Map request) { - return request.get("peerIp"); - } - } - - static class TestNetResponseAttributesExtractor - extends NetResponseAttributesExtractor, Map> { - - @Override - public String transport(Map response) { - return response.get("transport"); - } - - @Override - public String peerName(Map response) { - if (response != null) { - return response.get("peerName"); - } - return null; - } - - @Override - public Integer peerPort(Map response) { - if (response != null) { - return Integer.valueOf(response.get("peerPort")); - } - return null; - } - - @Override - public String peerIp(Map response) { - if (response != null) { - return response.get("peerIp"); - } - return null; - } - } - - @Test - void normal() { - // given - Map request = new HashMap<>(); - request.put("transport", "TCP"); - request.put("peerName", "github.com"); - request.put("peerPort", "123"); - request.put("peerIp", "1.2.3.4"); - - TestNetAttributesExtractor extractor = new TestNetAttributesExtractor(); - - // when - AttributesBuilder startAttributes = Attributes.builder(); - extractor.onStart(startAttributes, request); - - // then - assertThat(startAttributes.build()) - .containsOnly( - entry(SemanticAttributes.NET_TRANSPORT, "TCP"), - entry(SemanticAttributes.NET_PEER_NAME, "github.com"), - entry(SemanticAttributes.NET_PEER_PORT, 123L), - entry(SemanticAttributes.NET_PEER_IP, "1.2.3.4")); - } - - @Test - void responseAttributes() { - // given - Map request = new HashMap<>(); - request.put("transport", "TCP"); - request.put("peerName", "github.com"); - request.put("peerPort", "123"); - request.put("peerIp", "1.2.3.4"); - - Map response = new HashMap<>(); - response.put("peerName", "opentelemetry.io"); - response.put("peerPort", "42"); - response.put("peerIp", "4.3.2.1"); - - TestNetResponseAttributesExtractor extractor = new TestNetResponseAttributesExtractor(); - - // when - AttributesBuilder startAttributes = Attributes.builder(); - extractor.onStart(startAttributes, request); - - AttributesBuilder endAttributes = Attributes.builder(); - extractor.onEnd(endAttributes, request, response, null); - - // then - assertThat(startAttributes.build()) - .containsOnly( - entry(SemanticAttributes.NET_TRANSPORT, "TCP"), - entry(SemanticAttributes.NET_PEER_NAME, "github.com"), - entry(SemanticAttributes.NET_PEER_PORT, 123L), - entry(SemanticAttributes.NET_PEER_IP, "1.2.3.4")); - - assertThat(endAttributes.build()) - .containsOnly( - entry(SemanticAttributes.NET_PEER_NAME, "opentelemetry.io"), - entry(SemanticAttributes.NET_PEER_PORT, 42L), - entry(SemanticAttributes.NET_PEER_IP, "4.3.2.1")); - } - - @Test - public void doesNotSetDuplicateAttributes() { - // given - Map request = new HashMap<>(); - request.put("transport", "TCP"); - request.put("peerName", "1.2.3.4"); - request.put("peerIp", "1.2.3.4"); - request.put("peerPort", "123"); - - Map response = new HashMap<>(); - response.put("peerName", "4.3.2.1"); - response.put("peerPort", "42"); - response.put("peerIp", "4.3.2.1"); - - TestNetAttributesExtractor extractor = new TestNetAttributesExtractor(); - - // when - AttributesBuilder startAttributes = Attributes.builder(); - extractor.onStart(startAttributes, request); - - AttributesBuilder endAttributes = Attributes.builder(); - extractor.onEnd(endAttributes, request, response, null); - - // then - assertThat(startAttributes.build()) - .containsOnly( - entry(SemanticAttributes.NET_TRANSPORT, "TCP"), - entry(SemanticAttributes.NET_PEER_PORT, 123L), - entry(SemanticAttributes.NET_PEER_IP, "1.2.3.4")); - - assertThat(endAttributes.build()) - .containsOnly( - entry(SemanticAttributes.NET_PEER_PORT, 42L), - entry(SemanticAttributes.NET_PEER_IP, "4.3.2.1")); - } -} diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnEndExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnEndExtractorTest.java new file mode 100644 index 000000000000..d95a286fb8fd --- /dev/null +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnEndExtractorTest.java @@ -0,0 +1,107 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.api.instrumenter.net; + +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; +import static org.assertj.core.api.Assertions.entry; + +import io.opentelemetry.api.common.Attributes; +import io.opentelemetry.api.common.AttributesBuilder; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Test; + +class NetAttributesOnEndExtractorTest { + + static class TestNetAttributesOnEndExtractor + extends NetAttributesOnEndExtractor, Map> { + + @Override + public String transport(Map request, Map response) { + return response.get("transport"); + } + + @Override + public String peerName(Map request, Map response) { + if (response != null) { + return response.get("peerName"); + } + return null; + } + + @Override + public Integer peerPort(Map request, Map response) { + if (response != null) { + return Integer.valueOf(response.get("peerPort")); + } + return null; + } + + @Override + public String peerIp(Map request, Map response) { + if (response != null) { + return response.get("peerIp"); + } + return null; + } + } + + @Test + void normal() { + // given + Map request = new HashMap<>(); + request.put("transport", "TCP"); + request.put("peerName", "github.com"); + request.put("peerPort", "123"); + request.put("peerIp", "1.2.3.4"); + + Map response = new HashMap<>(); + response.put("peerName", "opentelemetry.io"); + response.put("peerPort", "42"); + response.put("peerIp", "4.3.2.1"); + + TestNetAttributesOnEndExtractor extractor = new TestNetAttributesOnEndExtractor(); + + // when + AttributesBuilder endAttributes = Attributes.builder(); + extractor.onEnd(endAttributes, request, response, null); + + // then + assertThat(endAttributes.build()) + .containsOnly( + entry(SemanticAttributes.NET_PEER_NAME, "opentelemetry.io"), + entry(SemanticAttributes.NET_PEER_PORT, 42L), + entry(SemanticAttributes.NET_PEER_IP, "4.3.2.1")); + } + + @Test + public void doesNotSetDuplicateAttributes() { + // given + Map request = new HashMap<>(); + request.put("transport", "TCP"); + request.put("peerName", "1.2.3.4"); + request.put("peerIp", "1.2.3.4"); + request.put("peerPort", "123"); + + Map response = new HashMap<>(); + response.put("peerName", "4.3.2.1"); + response.put("peerPort", "42"); + response.put("peerIp", "4.3.2.1"); + + TestNetAttributesOnEndExtractor extractor = new TestNetAttributesOnEndExtractor(); + + // when + AttributesBuilder endAttributes = Attributes.builder(); + extractor.onEnd(endAttributes, request, response, null); + + // then + assertThat(endAttributes.build()) + .containsOnly( + entry(SemanticAttributes.NET_PEER_PORT, 42L), + entry(SemanticAttributes.NET_PEER_IP, "4.3.2.1")); + } +} diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnStartExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnStartExtractorTest.java new file mode 100644 index 000000000000..f5ac7cb6f7d2 --- /dev/null +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnStartExtractorTest.java @@ -0,0 +1,90 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.api.instrumenter.net; + +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; +import static org.assertj.core.api.Assertions.entry; + +import io.opentelemetry.api.common.Attributes; +import io.opentelemetry.api.common.AttributesBuilder; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Test; + +class NetAttributesOnStartExtractorTest { + + static class TestNetAttributesOnStartExtractor + extends NetAttributesOnStartExtractor, Map> { + + @Override + public String transport(Map request) { + return request.get("transport"); + } + + @Override + public String peerName(Map request) { + return request.get("peerName"); + } + + @Override + public Integer peerPort(Map request) { + return Integer.valueOf(request.get("peerPort")); + } + + @Override + public String peerIp(Map request) { + return request.get("peerIp"); + } + } + + @Test + void normal() { + // given + Map request = new HashMap<>(); + request.put("transport", "TCP"); + request.put("peerName", "github.com"); + request.put("peerPort", "123"); + request.put("peerIp", "1.2.3.4"); + + TestNetAttributesOnStartExtractor extractor = new TestNetAttributesOnStartExtractor(); + + // when + AttributesBuilder startAttributes = Attributes.builder(); + extractor.onStart(startAttributes, request); + + // then + assertThat(startAttributes.build()) + .containsOnly( + entry(SemanticAttributes.NET_TRANSPORT, "TCP"), + entry(SemanticAttributes.NET_PEER_NAME, "github.com"), + entry(SemanticAttributes.NET_PEER_PORT, 123L), + entry(SemanticAttributes.NET_PEER_IP, "1.2.3.4")); + } + + @Test + public void doesNotSetDuplicateAttributes() { + // given + Map request = new HashMap<>(); + request.put("transport", "TCP"); + request.put("peerName", "1.2.3.4"); + request.put("peerIp", "1.2.3.4"); + request.put("peerPort", "123"); + + TestNetAttributesOnStartExtractor extractor = new TestNetAttributesOnStartExtractor(); + + // when + AttributesBuilder startAttributes = Attributes.builder(); + extractor.onStart(startAttributes, request); + + // then + assertThat(startAttributes.build()) + .containsOnly( + entry(SemanticAttributes.NET_TRANSPORT, "TCP"), + entry(SemanticAttributes.NET_PEER_PORT, 123L), + entry(SemanticAttributes.NET_PEER_IP, "1.2.3.4")); + } +} diff --git a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetAttributesExtractor.java b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetAttributesExtractor.java index 42b426c2aff6..1730385ec954 100644 --- a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetAttributesExtractor.java +++ b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetAttributesExtractor.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.InetSocketAddressNetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnStartExtractor; import java.net.InetSocketAddress; import org.apache.dubbo.rpc.Result; import org.checkerframework.checker.nullness.qual.Nullable; public final class DubboNetAttributesExtractor - extends InetSocketAddressNetAttributesExtractor { + extends InetSocketAddressNetAttributesOnStartExtractor { @Override public @Nullable InetSocketAddress getAddress(DubboRequest request) { 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/ApacheHttpAsyncClientNetAttributesExtractor.java index afeccee74d6c..e6a1b637dead 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/ApacheHttpAsyncClientNetAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpasyncclient; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.http.HttpResponse; import org.checkerframework.checker.nullness.qual.Nullable; final class ApacheHttpAsyncClientNetAttributesExtractor - extends NetAttributesExtractor { + extends NetAttributesOnStartExtractor { @Override public String transport(ApacheHttpClientRequest request) { 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/ApacheHttpClientNetAttributesExtractor.java index 88e5b7b2e294..5f895ac2f46f 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/ApacheHttpClientNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.commons.httpclient.HostConfiguration; import org.apache.commons.httpclient.HttpMethod; import org.checkerframework.checker.nullness.qual.Nullable; final class ApacheHttpClientNetAttributesExtractor - extends NetAttributesExtractor { + extends NetAttributesOnStartExtractor { @Override public String transport(HttpMethod request) { 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/ApacheHttpClientNetAttributesExtractor.java index 9026f6fbe5a6..2b3e17a73be9 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/ApacheHttpClientNetAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v4_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.http.HttpResponse; import org.checkerframework.checker.nullness.qual.Nullable; final class ApacheHttpClientNetAttributesExtractor - extends NetAttributesExtractor { + extends NetAttributesOnStartExtractor { @Override public String transport(ApacheHttpClientRequest request) { 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/ApacheHttpClientNetAttributesExtractor.java index 9545dc5e50d4..90145f3d1a5f 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/ApacheHttpClientNetAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.instrumentation.apachehttpclient.v4_3; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.http.HttpResponse; import org.checkerframework.checker.nullness.qual.Nullable; final class ApacheHttpClientNetAttributesExtractor - extends NetAttributesExtractor { + extends NetAttributesOnStartExtractor { @Override public String transport(ApacheHttpClientRequest request) { 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/ApacheHttpClientNetAttributesExtractor.java index d954d2d70399..1eb08e2e7bc3 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/ApacheHttpClientNetAttributesExtractor.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v5_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.HttpResponse; @@ -14,7 +14,7 @@ import org.slf4j.LoggerFactory; final class ApacheHttpClientNetAttributesExtractor - extends NetAttributesExtractor { + extends NetAttributesOnStartExtractor { private static final Logger logger = LoggerFactory.getLogger(ApacheHttpClientNetAttributesExtractor.class); diff --git a/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetAttributesExtractor.java b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetAttributesExtractor.java index 163e6b288358..09d4516c4808 100644 --- a/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetAttributesExtractor.java +++ b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetAttributesExtractor.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.InetSocketAddressNetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import java.net.SocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; public final class ArmeriaNetAttributesExtractor - extends InetSocketAddressNetAttributesExtractor { + extends InetSocketAddressNetAttributesOnStartExtractor { @Override public String transport(RequestContext ctx) { 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/AsyncHttpClientNetAttributesExtractor.java index e5776d9e96e4..7b2d0de0b385 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/AsyncHttpClientNetAttributesExtractor.java @@ -7,12 +7,12 @@ import com.ning.http.client.Request; import com.ning.http.client.Response; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; final class AsyncHttpClientNetAttributesExtractor - extends NetAttributesExtractor { + extends NetAttributesOnStartExtractor { @Override public String transport(Request request) { 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/AsyncHttpClientNetAttributesExtractor.java index 53479ef0c01f..212d1908baca 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/AsyncHttpClientNetAttributesExtractor.java @@ -5,22 +5,23 @@ package io.opentelemetry.javaagent.instrumentation.asynchttpclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetResponseAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnEndExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import org.asynchttpclient.Response; import org.checkerframework.checker.nullness.qual.Nullable; final class AsyncHttpClientNetAttributesExtractor - extends InetSocketAddressNetResponseAttributesExtractor { + extends InetSocketAddressNetAttributesOnEndExtractor { @Override - public String transport(@Nullable Response response) { + public String transport(RequestContext request, @Nullable Response response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public @Nullable InetSocketAddress getAddress(@Nullable Response response) { + public @Nullable InetSocketAddress getAddress( + RequestContext request, @Nullable Response response) { if (response != null && response.getRemoteAddress() instanceof InetSocketAddress) { return (InetSocketAddress) response.getRemoteAddress(); } 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 c802785097d5..14aaf5af0caa 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 @@ -13,7 +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.NetResponseAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnEndExtractor; import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceResponseAttributesExtractor; import org.asynchttpclient.Response; @@ -29,7 +29,7 @@ public final class AsyncHttpClientSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetResponseAttributesExtractor netAttributesExtractor = + NetAttributesOnEndExtractor netAttributesExtractor = new AsyncHttpClientNetAttributesExtractor(); INSTRUMENTER = 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/CassandraNetAttributesExtractor.java index 7ed7b9949e4a..629c52b0cfdd 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/CassandraNetAttributesExtractor.java @@ -6,21 +6,22 @@ package io.opentelemetry.javaagent.instrumentation.cassandra.v3_0; import com.datastax.driver.core.ExecutionInfo; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetResponseAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnEndExtractor; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; final class CassandraNetAttributesExtractor - extends InetSocketAddressNetResponseAttributesExtractor { + extends InetSocketAddressNetAttributesOnEndExtractor { @Override @Nullable - public String transport(@Nullable ExecutionInfo executionInfo) { + public String transport(CassandraRequest request, @Nullable ExecutionInfo executionInfo) { return null; } @Override - public @Nullable InetSocketAddress getAddress(@Nullable ExecutionInfo executionInfo) { + public @Nullable InetSocketAddress getAddress( + CassandraRequest request, @Nullable ExecutionInfo executionInfo) { return executionInfo == null ? null : executionInfo.getQueriedHost().getSocketAddress(); } } 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/CassandraNetAttributesExtractor.java index b919fd669331..b9d288e890f9 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/CassandraNetAttributesExtractor.java @@ -7,22 +7,23 @@ 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.InetSocketAddressNetResponseAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnEndExtractor; import java.net.InetSocketAddress; import java.net.SocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; final class CassandraNetAttributesExtractor - extends InetSocketAddressNetResponseAttributesExtractor { + extends InetSocketAddressNetAttributesOnEndExtractor { @Override @Nullable - public String transport(@Nullable ExecutionInfo executionInfo) { + public String transport(CassandraRequest request, @Nullable ExecutionInfo executionInfo) { return null; } @Override - public @Nullable InetSocketAddress getAddress(@Nullable ExecutionInfo executionInfo) { + public @Nullable InetSocketAddress getAddress( + CassandraRequest request, @Nullable ExecutionInfo executionInfo) { if (executionInfo == null) { return null; } diff --git a/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestAttributesExtractor.java b/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestAttributesExtractor.java index 08ac57fb0a3c..00aace1c117b 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestAttributesExtractor.java +++ b/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestAttributesExtractor.java @@ -12,27 +12,27 @@ final class ElasticsearchRestAttributesExtractor extends DbAttributesExtractor { @Override - protected String system(String s) { + protected String system(String operation) { return SemanticAttributes.DbSystemValues.ELASTICSEARCH; } @Override - protected @Nullable String user(String s) { + protected @Nullable String user(String operation) { return null; } @Override - protected @Nullable String name(String s) { + protected @Nullable String name(String operation) { return null; } @Override - protected @Nullable String connectionString(String s) { + protected @Nullable String connectionString(String operation) { return null; } @Override - protected @Nullable String statement(String s) { + protected @Nullable String statement(String operation) { return null; } 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/ElasticsearchRestNetResponseAttributesExtractor.java index 10ffaa8da950..6bde0840a5b4 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/ElasticsearchRestNetResponseAttributesExtractor.java @@ -5,20 +5,20 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.rest; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetResponseAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnEndExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; import org.elasticsearch.client.Response; final class ElasticsearchRestNetResponseAttributesExtractor - extends NetResponseAttributesExtractor { + extends NetAttributesOnEndExtractor { @Override - public String transport(Response response) { + public String transport(String operation, Response response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public @Nullable String peerName(@Nullable Response response) { + public @Nullable String peerName(String operation, @Nullable Response response) { if (response != null) { return response.getHost().getHostName(); } @@ -26,7 +26,7 @@ public String transport(Response response) { } @Override - public @Nullable Integer peerPort(@Nullable Response response) { + public @Nullable Integer peerPort(String operation, @Nullable Response response) { if (response != null) { return response.getHost().getPort(); } @@ -34,7 +34,7 @@ public String transport(Response response) { } @Override - public @Nullable String peerIp(@Nullable Response response) { + public @Nullable String peerIp(String operation, @Nullable Response response) { if (response != null && response.getHost().getAddress() != null) { return response.getHost().getAddress().getHostAddress(); } 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/Elasticsearch6TransportNetAttributesExtractor.java index e652aae0f337..92da5b36b105 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/Elasticsearch6TransportNetAttributesExtractor.java @@ -5,22 +5,23 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.v6_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetResponseAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnEndExtractor; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportRequest; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; import org.elasticsearch.action.ActionResponse; public class Elasticsearch6TransportNetAttributesExtractor - extends InetSocketAddressNetResponseAttributesExtractor< - ElasticTransportRequest, ActionResponse> { + extends InetSocketAddressNetAttributesOnEndExtractor { @Override - public @Nullable String transport(@Nullable ActionResponse response) { + public @Nullable String transport( + ElasticTransportRequest request, @Nullable ActionResponse response) { return null; } @Override - public @Nullable InetSocketAddress getAddress(@Nullable ActionResponse response) { + public @Nullable InetSocketAddress getAddress( + ElasticTransportRequest request, @Nullable ActionResponse response) { if (response != null && response.remoteAddress() != null) { return response.remoteAddress().address(); } 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/ElasticTransportNetResponseAttributesExtractor.java index 6e867c19b441..ad219a533337 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/ElasticTransportNetResponseAttributesExtractor.java @@ -5,19 +5,21 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetResponseAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnEndExtractor; import org.checkerframework.checker.nullness.qual.Nullable; import org.elasticsearch.action.ActionResponse; public class ElasticTransportNetResponseAttributesExtractor - extends NetResponseAttributesExtractor { + extends NetAttributesOnEndExtractor { @Override - public @Nullable String transport(@Nullable ActionResponse response) { + public @Nullable String transport( + ElasticTransportRequest request, @Nullable ActionResponse response) { return null; } @Override - public @Nullable String peerName(@Nullable ActionResponse response) { + public @Nullable String peerName( + ElasticTransportRequest request, @Nullable ActionResponse response) { if (response != null && response.remoteAddress() != null) { return response.remoteAddress().getHost(); } @@ -25,7 +27,8 @@ public class ElasticTransportNetResponseAttributesExtractor } @Override - public @Nullable Integer peerPort(@Nullable ActionResponse response) { + public @Nullable Integer peerPort( + ElasticTransportRequest request, @Nullable ActionResponse response) { if (response != null && response.remoteAddress() != null) { return response.remoteAddress().getPort(); } @@ -33,7 +36,8 @@ public class ElasticTransportNetResponseAttributesExtractor } @Override - public @Nullable String peerIp(@Nullable ActionResponse response) { + public @Nullable String peerIp( + ElasticTransportRequest request, @Nullable ActionResponse response) { if (response != null && response.remoteAddress() != null) { return response.remoteAddress().getAddress(); } 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/GoogleHttpClientNetAttributesExtractor.java index 52ffae2435cb..eb1a5f482c3f 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/GoogleHttpClientNetAttributesExtractor.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.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; final class GoogleHttpClientNetAttributesExtractor - extends NetAttributesExtractor { + extends NetAttributesOnStartExtractor { @Override public String transport(HttpRequest request) { diff --git a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetAttributesExtractor.java b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetAttributesExtractor.java index e5431c9fce82..de58c0410841 100644 --- a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetAttributesExtractor.java +++ b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetAttributesExtractor.java @@ -6,7 +6,7 @@ package io.opentelemetry.instrumentation.grpc.v1_6.internal; import io.grpc.Status; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnStartExtractor; import io.opentelemetry.instrumentation.grpc.v1_6.GrpcRequest; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; @@ -14,7 +14,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; public final class GrpcNetAttributesExtractor - extends InetSocketAddressNetAttributesExtractor { + extends InetSocketAddressNetAttributesOnStartExtractor { @Override @Nullable public InetSocketAddress getAddress(GrpcRequest request) { 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/HttpUrlNetAttributesExtractor.java index 939a0118fb32..cd79acd02eeb 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/HttpUrlNetAttributesExtractor.java @@ -5,12 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.httpurlconnection; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.HttpURLConnection; import org.checkerframework.checker.nullness.qual.Nullable; -class HttpUrlNetAttributesExtractor extends NetAttributesExtractor { +class HttpUrlNetAttributesExtractor + extends NetAttributesOnStartExtractor { @Override public @Nullable String transport(HttpURLConnection connection) { return SemanticAttributes.NetTransportValues.IP_TCP; 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/JdkHttpNetAttributesExtractor.java index 7d55560cb82e..b8bfcf3c1e07 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/JdkHttpNetAttributesExtractor.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.httpclient; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.http.HttpRequest; import java.net.http.HttpResponse; @@ -14,7 +14,7 @@ import org.slf4j.LoggerFactory; public class JdkHttpNetAttributesExtractor - extends NetAttributesExtractor> { + extends NetAttributesOnStartExtractor> { private static final Logger logger = LoggerFactory.getLogger(JdkHttpNetAttributesExtractor.class); 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/JaxRsClientNetAttributesExtractor.java index 961eccb81dc3..d0a5b61b7570 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/JaxRsClientNetAttributesExtractor.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.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; final class JaxRsClientNetAttributesExtractor - extends NetAttributesExtractor { + extends NetAttributesOnStartExtractor { @Override public String transport(ClientRequest request) { 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/JaxRsClientNetAttributesExtractor.java index 0a56b5e7f967..ed05290526c5 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/JaxRsClientNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.jaxrsclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.ws.rs.client.ClientRequestContext; import javax.ws.rs.client.ClientResponseContext; import org.checkerframework.checker.nullness.qual.Nullable; final class JaxRsClientNetAttributesExtractor - extends NetAttributesExtractor { + extends NetAttributesOnStartExtractor { @Override public String transport(ClientRequestContext request) { 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/ResteasyClientNetAttributesExtractor.java index d6728f5d3483..d6f86efc2f8f 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/ResteasyClientNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.jaxrsclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.ws.rs.core.Response; import org.checkerframework.checker.nullness.qual.Nullable; import org.jboss.resteasy.client.jaxrs.internal.ClientInvocation; final class ResteasyClientNetAttributesExtractor - extends NetAttributesExtractor { + extends NetAttributesOnStartExtractor { @Override public String transport(ClientInvocation request) { 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/JdbcNetAttributesExtractor.java index 0028f423d824..1692516b8d09 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/JdbcNetAttributesExtractor.java @@ -5,10 +5,11 @@ package io.opentelemetry.instrumentation.jdbc.internal; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import org.checkerframework.checker.nullness.qual.Nullable; -public final class JdbcNetAttributesExtractor extends NetAttributesExtractor { +public final class JdbcNetAttributesExtractor + extends NetAttributesOnStartExtractor { @Nullable @Override 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/JedisNetAttributesExtractor.java index 9ef355d48885..4a13e066791c 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/JedisNetAttributesExtractor.java @@ -5,10 +5,10 @@ package io.opentelemetry.javaagent.instrumentation.jedis.v1_4; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import org.checkerframework.checker.nullness.qual.Nullable; -final class JedisNetAttributesExtractor extends NetAttributesExtractor { +final class JedisNetAttributesExtractor extends NetAttributesOnStartExtractor { @Override @Nullable 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/JedisNetAttributesExtractor.java index f6c424d3207a..656347022b67 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/JedisNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.jedis.v3_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import java.net.Socket; import org.checkerframework.checker.nullness.qual.Nullable; final class JedisNetAttributesExtractor - extends InetSocketAddressNetAttributesExtractor { + extends InetSocketAddressNetAttributesOnStartExtractor { @Override public @Nullable InetSocketAddress getAddress(JedisRequest jedisRequest) { 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/JettyHttpClientNetAttributesExtractor.java index d8b806a36879..148ab6746f54 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/JettyHttpClientNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.api.Response; public class JettyHttpClientNetAttributesExtractor - extends NetAttributesExtractor { + extends NetAttributesOnStartExtractor { @Override public String transport(Request request) { 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/KubernetesNetAttributesExtractor.java index b5b4f5d2f0f6..26f2b72da18e 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/KubernetesNetAttributesExtractor.java @@ -6,12 +6,13 @@ package io.opentelemetry.javaagent.instrumentation.kubernetesclient; import io.kubernetes.client.openapi.ApiResponse; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import okhttp3.Request; import org.checkerframework.checker.nullness.qual.Nullable; -class KubernetesNetAttributesExtractor extends NetAttributesExtractor> { +class KubernetesNetAttributesExtractor + extends NetAttributesOnStartExtractor> { @Override public String transport(Request request) { 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/LettuceConnectNetAttributesExtractor.java index d85d784b2421..e6724de16d90 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/LettuceConnectNetAttributesExtractor.java @@ -6,10 +6,11 @@ package io.opentelemetry.javaagent.instrumentation.lettuce.v4_0; import com.lambdaworks.redis.RedisURI; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import org.checkerframework.checker.nullness.qual.Nullable; -final class LettuceConnectNetAttributesExtractor extends NetAttributesExtractor { +final class LettuceConnectNetAttributesExtractor + extends NetAttributesOnStartExtractor { @Override @Nullable 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/LettuceConnectNetAttributesExtractor.java index f98d289ede7c..c1b1dbb07b2f 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/LettuceConnectNetAttributesExtractor.java @@ -6,10 +6,11 @@ package io.opentelemetry.javaagent.instrumentation.lettuce.v5_0; import io.lettuce.core.RedisURI; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import org.checkerframework.checker.nullness.qual.Nullable; -final class LettuceConnectNetAttributesExtractor extends NetAttributesExtractor { +final class LettuceConnectNetAttributesExtractor + extends NetAttributesOnStartExtractor { @Override @Nullable diff --git a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesExtractor.java b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesExtractor.java index 90ceca6a25ee..d016acb1a9af 100644 --- a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesExtractor.java +++ b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesExtractor.java @@ -5,12 +5,12 @@ package io.opentelemetry.javaagent.instrumentation.liberty.dispatcher; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; public class LibertyDispatcherNetAttributesExtractor - extends NetAttributesExtractor { + extends NetAttributesOnStartExtractor { @Override public String transport(LibertyRequest libertyRequest) { diff --git a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java index c7925cf3c2f1..4fae889f9609 100644 --- a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java +++ b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java @@ -15,7 +15,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.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; @@ -31,7 +31,7 @@ public final class LibertyDispatcherSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetAttributesExtractor netAttributesExtractor = + NetAttributesOnStartExtractor netAttributesExtractor = new LibertyDispatcherNetAttributesExtractor(); INSTRUMENTER = 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/OkHttp2NetAttributesExtractor.java index 7a25a592f6b3..5ab37e39d9e6 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/OkHttp2NetAttributesExtractor.java @@ -7,11 +7,12 @@ import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; -public final class OkHttp2NetAttributesExtractor extends NetAttributesExtractor { +public final class OkHttp2NetAttributesExtractor + extends NetAttributesOnStartExtractor { @Override public String transport(Request request) { 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 9fab0ee94785..a1c283ebb005 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 @@ -19,7 +19,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.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; public final class OkHttp2Singletons { @@ -35,7 +35,7 @@ public final class OkHttp2Singletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetAttributesExtractor netAttributesExtractor = + NetAttributesOnStartExtractor netAttributesExtractor = new OkHttp2NetAttributesExtractor(); OpenTelemetry openTelemetry = GlobalOpenTelemetry.get(); 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/OkHttpNetAttributesExtractor.java index dad02f758ea8..c9f836eb5157 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/OkHttpNetAttributesExtractor.java @@ -5,13 +5,14 @@ package io.opentelemetry.instrumentation.okhttp.v3_0.internal; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import okhttp3.Request; import okhttp3.Response; import org.checkerframework.checker.nullness.qual.Nullable; -public final class OkHttpNetAttributesExtractor extends NetAttributesExtractor { +public final class OkHttpNetAttributesExtractor + extends NetAttributesOnStartExtractor { @Override public String transport(Request request) { 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/PlayWsClientNetAttributesExtractor.java index 2a6b12b863dd..5e741ec22cf3 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/PlayWsClientNetAttributesExtractor.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.playws; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetResponseAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnEndExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; @@ -13,15 +13,15 @@ import play.shaded.ahc.org.asynchttpclient.Response; final class PlayWsClientNetAttributesExtractor - extends InetSocketAddressNetResponseAttributesExtractor { + extends InetSocketAddressNetAttributesOnEndExtractor { @Override - public String transport(@Nullable Response response) { + public String transport(Request request, @Nullable Response response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public @Nullable InetSocketAddress getAddress(@Nullable Response response) { + public @Nullable InetSocketAddress getAddress(Request request, @Nullable Response response) { if (response != null && response.getRemoteAddress() instanceof InetSocketAddress) { return (InetSocketAddress) response.getRemoteAddress(); } diff --git a/instrumentation/ratpack-1.4/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesExtractor.java b/instrumentation/ratpack-1.4/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesExtractor.java index 715c81ecf449..6cf4b37ec65c 100644 --- a/instrumentation/ratpack-1.4/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesExtractor.java +++ b/instrumentation/ratpack-1.4/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesExtractor.java @@ -5,13 +5,14 @@ package io.opentelemetry.instrumentation.ratpack.internal; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; import ratpack.http.Request; import ratpack.http.Response; -public final class RatpackNetAttributesExtractor extends NetAttributesExtractor { +public final class RatpackNetAttributesExtractor + extends NetAttributesOnStartExtractor { @Override @Nullable public String transport(Request request) { 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/RedissonNetAttributesExtractor.java index 9a70b271ab45..6d88379f9ada 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/RedissonNetAttributesExtractor.java @@ -5,12 +5,12 @@ package io.opentelemetry.javaagent.instrumentation.redisson; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnStartExtractor; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; final class RedissonNetAttributesExtractor - extends InetSocketAddressNetAttributesExtractor { + extends InetSocketAddressNetAttributesOnStartExtractor { @Override public InetSocketAddress getAddress(RedissonRequest request) { diff --git a/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesExtractor.java b/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesExtractor.java index 1df4dbb52d54..aa4cfbe6cce3 100644 --- a/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesExtractor.java +++ b/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.instrumentation.restlet.v1_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; import org.restlet.data.Request; import org.restlet.data.Response; -final class RestletNetAttributesExtractor extends NetAttributesExtractor { +final class RestletNetAttributesExtractor extends NetAttributesOnStartExtractor { @Override public String transport(Request request) { return SemanticAttributes.NetTransportValues.IP_TCP; diff --git a/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletTracingBuilder.java b/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletTracingBuilder.java index 67548bc35a0b..43d4f0f868be 100644 --- a/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletTracingBuilder.java +++ b/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletTracingBuilder.java @@ -12,7 +12,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import java.util.ArrayList; import java.util.List; import org.restlet.data.Request; @@ -50,7 +50,7 @@ public RestletTracing build() { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetAttributesExtractor netAttributesExtractor = + NetAttributesOnStartExtractor netAttributesExtractor = new RestletNetAttributesExtractor(); Instrumenter instrumenter = diff --git a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesExtractor.java b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesExtractor.java index 548cca6d3f9c..34ca02aaa59b 100644 --- a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesExtractor.java +++ b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesExtractor.java @@ -5,12 +5,12 @@ package io.opentelemetry.javaagent.instrumentation.servlet; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.instrumentation.servlet.ServletAccessor; import org.checkerframework.checker.nullness.qual.Nullable; public class ServletNetAttributesExtractor - extends NetAttributesExtractor< + extends NetAttributesOnStartExtractor< ServletRequestContext, ServletResponseContext> { private final ServletAccessor accessor; diff --git a/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesExtractor.java b/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesExtractor.java index 3b1a4ec93401..d8a8f8345723 100644 --- a/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesExtractor.java +++ b/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.instrumentation.spring.web; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; import org.springframework.http.HttpRequest; import org.springframework.http.client.ClientHttpResponse; final class SpringWebNetAttributesExtractor - extends NetAttributesExtractor { + extends NetAttributesOnStartExtractor { @Override public String transport(HttpRequest httpRequest) { return SemanticAttributes.NetTransportValues.IP_TCP; diff --git a/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesExtractor.java b/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesExtractor.java index e32db1be7ddf..f0e333701dd1 100644 --- a/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesExtractor.java +++ b/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.instrumentation.spring.webmvc; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.checkerframework.checker.nullness.qual.Nullable; final class SpringWebMvcNetAttributesExtractor - extends NetAttributesExtractor { + extends NetAttributesOnStartExtractor { @Override public String transport(HttpServletRequest request) { return SemanticAttributes.NetTransportValues.IP_TCP; diff --git a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java index b4341e1f612a..62a3695ba0dc 100644 --- a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java +++ b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java @@ -16,7 +16,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.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.instrumentation.api.servlet.AppServerBridge; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; import io.opentelemetry.instrumentation.servlet.ServletAccessor; @@ -39,7 +39,7 @@ public static Instrumenter newInstrumente HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetAttributesExtractor netAttributesExtractor = + NetAttributesOnStartExtractor netAttributesExtractor = new TomcatNetAttributesExtractor(); AttributesExtractor additionalAttributeExtractor = new TomcatAdditionalAttributesExtractor<>(accessor, servletEntityProvider); diff --git a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesExtractor.java b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesExtractor.java index dafa9b67cc38..cc9b8b583f84 100644 --- a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesExtractor.java +++ b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.tomcat.common; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import org.apache.coyote.ActionCode; import org.apache.coyote.Request; import org.apache.coyote.Response; import org.checkerframework.checker.nullness.qual.Nullable; -public class TomcatNetAttributesExtractor extends NetAttributesExtractor { +public class TomcatNetAttributesExtractor extends NetAttributesOnStartExtractor { @Override public @Nullable String transport(Request request) { diff --git a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowNetAttributesExtractor.java b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowNetAttributesExtractor.java index f21456ad9543..26ce41de4ec1 100644 --- a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowNetAttributesExtractor.java +++ b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.undertow; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import io.undertow.server.HttpServerExchange; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; public class UndertowNetAttributesExtractor - extends InetSocketAddressNetAttributesExtractor { + extends InetSocketAddressNetAttributesOnStartExtractor { @Override public @Nullable InetSocketAddress getAddress(HttpServerExchange exchange) { diff --git a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java index a7a8e6f96c56..1c28a49e6331 100644 --- a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java +++ b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java @@ -15,7 +15,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.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.instrumentation.api.servlet.AppServerBridge; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; import io.opentelemetry.javaagent.bootstrap.undertow.UndertowActiveHandlers; @@ -34,7 +34,7 @@ public final class UndertowSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetAttributesExtractor netAttributesExtractor = + NetAttributesOnStartExtractor netAttributesExtractor = new UndertowNetAttributesExtractor(); INSTRUMENTER = diff --git a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java index f41da98e74fb..c6e46421d87d 100644 --- a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java +++ b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java @@ -8,7 +8,7 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.instrumentation.api.config.Config; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.Map; import org.checkerframework.checker.nullness.qual.Nullable; @@ -28,12 +28,12 @@ public final class PeerServiceAttributesExtractor Config.get().getMap("otel.instrumentation.common.peer-service-mapping"); private final Map peerServiceMapping; - private final NetAttributesExtractor netAttributesExtractor; + private final NetAttributesOnStartExtractor netAttributesExtractor; // visible for tests PeerServiceAttributesExtractor( Map peerServiceMapping, - NetAttributesExtractor netAttributesExtractor) { + NetAttributesOnStartExtractor netAttributesExtractor) { this.peerServiceMapping = peerServiceMapping; this.netAttributesExtractor = netAttributesExtractor; } @@ -43,7 +43,7 @@ public final class PeerServiceAttributesExtractor * netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute. */ public static PeerServiceAttributesExtractor create( - NetAttributesExtractor netAttributesExtractor) { + NetAttributesOnStartExtractor netAttributesExtractor) { return new PeerServiceAttributesExtractor<>( JAVAAGENT_PEER_SERVICE_MAPPING, netAttributesExtractor); } diff --git a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceResponseAttributesExtractor.java b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceResponseAttributesExtractor.java index ed52e909f1d5..f7f577b5e6a6 100644 --- a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceResponseAttributesExtractor.java +++ b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceResponseAttributesExtractor.java @@ -8,7 +8,7 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.instrumentation.api.config.Config; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetResponseAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnEndExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.Map; import org.checkerframework.checker.nullness.qual.Nullable; @@ -28,12 +28,12 @@ public final class PeerServiceResponseAttributesExtractor Config.get().getMap("otel.instrumentation.common.peer-service-mapping"); private final Map peerServiceMapping; - private final NetResponseAttributesExtractor netResponseAttributesExtractor; + private final NetAttributesOnEndExtractor netResponseAttributesExtractor; // visible for tests PeerServiceResponseAttributesExtractor( Map peerServiceMapping, - NetResponseAttributesExtractor netResponseAttributesExtractor) { + NetAttributesOnEndExtractor netResponseAttributesExtractor) { this.peerServiceMapping = peerServiceMapping; this.netResponseAttributesExtractor = netResponseAttributesExtractor; } @@ -44,7 +44,7 @@ public final class PeerServiceResponseAttributesExtractor */ public static PeerServiceResponseAttributesExtractor create( - NetResponseAttributesExtractor netResponseAttributesExtractor) { + NetAttributesOnEndExtractor netResponseAttributesExtractor) { return new PeerServiceResponseAttributesExtractor<>( JAVAAGENT_PEER_SERVICE_MAPPING, netResponseAttributesExtractor); } diff --git a/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractorTest.java b/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractorTest.java index 63b65316de0b..dafaf188228b 100644 --- a/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractorTest.java +++ b/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/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.NetAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; 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 NetAttributesExtractor netAttributesExtractor; + @Mock NetAttributesOnStartExtractor netAttributesExtractor; @Test void shouldNotSetAnyValueIfNetExtractorReturnsNulls() { From 7ae5fa1f93067e96d2912cc252f30f1197dbdef3 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Mon, 4 Oct 2021 12:27:45 -0700 Subject: [PATCH 05/26] PeerServiceAttributes --- .../apachedubbo/v2_7/OpenTelemetryFilter.java | 5 +- .../ApacheHttpAsyncClientSingletons.java | 5 +- .../v2_0/ApacheHttpClientSingletons.java | 5 +- .../v4_0/ApacheHttpClientSingletons.java | 5 +- .../v5_0/ApacheHttpClientSingletons.java | 5 +- .../armeria/v1_3/ArmeriaSingletons.java | 7 +- .../v1_9/AsyncHttpClientSingletons.java | 5 +- .../v2_0/AsyncHttpClientSingletons.java | 4 +- .../ElasticsearchRestInstrumenterFactory.java | 5 +- .../GoogleHttpClientSingletons.java | 5 +- .../grpc/v1_6/GrpcSingletons.java | 6 +- .../HttpUrlConnectionSingletons.java | 5 +- .../httpclient/JdkHttpClientSingletons.java | 5 +- .../v1_1/JaxRsClientSingletons.java | 5 +- .../v2_0/JaxRsClientSingletons.java | 5 +- .../v2_0/ResteasyClientSingletons.java | 5 +- .../instrumentation/jdbc/JdbcSingletons.java | 5 +- .../jedis/v1_4/JedisSingletons.java | 5 +- .../jedis/v3_0/JedisSingletons.java | 5 +- .../v9_2/JettyHttpClientSingletons.java | 6 +- .../lettuce/v4_0/LettuceSingletons.java | 4 +- .../lettuce/v5_0/LettuceSingletons.java | 4 +- .../LibertyDispatcherSingletons.java | 5 +- .../okhttp/v2_2/OkHttp2Singletons.java | 5 +- .../okhttp/v3_0/OkHttp3Singletons.java | 4 +- .../playws/PlayWsClientSingletons.java | 4 +- .../servlet/ServletInstrumenterBuilder.java | 5 +- .../common/TomcatInstrumenterBuilder.java | 5 +- .../undertow/UndertowSingletons.java | 5 +- ... PeerServiceAttributesOnEndExtractor.java} | 21 ++- ...eerServiceAttributesOnStartExtractor.java} | 10 +- ...rServiceAttributesOnEndExtractorTest.java} | 32 ++-- ...ServiceAttributesOnStartExtractorTest.java | 137 ++++++++++++++++++ 33 files changed, 248 insertions(+), 96 deletions(-) rename javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/{PeerServiceResponseAttributesExtractor.java => PeerServiceAttributesOnEndExtractor.java} (81%) rename javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/{PeerServiceAttributesExtractor.java => PeerServiceAttributesOnStartExtractor.java} (88%) rename javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/{PeerServiceAttributesExtractorTest.java => PeerServiceAttributesOnEndExtractorTest.java} (78%) create mode 100644 javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractorTest.java diff --git a/instrumentation/apache-dubbo-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachedubbo/v2_7/OpenTelemetryFilter.java b/instrumentation/apache-dubbo-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachedubbo/v2_7/OpenTelemetryFilter.java index eed075a954d9..a2c1c44bd8c0 100644 --- a/instrumentation/apache-dubbo-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachedubbo/v2_7/OpenTelemetryFilter.java +++ b/instrumentation/apache-dubbo-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachedubbo/v2_7/OpenTelemetryFilter.java @@ -8,7 +8,7 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.apachedubbo.v2_7.DubboTracing; import io.opentelemetry.instrumentation.apachedubbo.v2_7.internal.DubboNetAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; import org.apache.dubbo.common.extension.Activate; import org.apache.dubbo.rpc.Filter; import org.apache.dubbo.rpc.Invocation; @@ -24,7 +24,8 @@ public OpenTelemetryFilter() { DubboNetAttributesExtractor netAttributesExtractor = new DubboNetAttributesExtractor(); delegate = DubboTracing.newBuilder(GlobalOpenTelemetry.get()) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) .build() .newFilter(); } 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 c28a86c0264e..37fc0bf7f28a 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 @@ -13,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; import org.apache.http.HttpResponse; public final class ApacheHttpAsyncClientSingletons { @@ -37,7 +37,8 @@ public final class ApacheHttpAsyncClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } 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 2bc0896b42e9..3cb235004a0a 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 @@ -13,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; import org.apache.commons.httpclient.HttpMethod; public final class ApacheHttpClientSingletons { @@ -37,7 +37,8 @@ public final class ApacheHttpClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } 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 be172f12934d..7f026ddc2de5 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 @@ -13,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; import org.apache.http.HttpResponse; public final class ApacheHttpClientSingletons { @@ -37,7 +37,8 @@ public final class ApacheHttpClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } 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 26ffb50bc155..8be1abb399c9 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 @@ -13,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.HttpResponse; @@ -38,7 +38,8 @@ public final class ApacheHttpClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } diff --git a/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java b/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java index c83960cad4d9..566ca4f96ba0 100644 --- a/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java +++ b/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java @@ -12,7 +12,7 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.armeria.v1_3.ArmeriaTracing; import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaNetAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; import java.util.function.Function; // Holds singleton references to decorators to match against during suppression. @@ -23,8 +23,9 @@ public final class ArmeriaSingletons { public static final Function SERVER_DECORATOR; static { - PeerServiceAttributesExtractor peerServiceAttributesExtractor = - PeerServiceAttributesExtractor.create(new ArmeriaNetAttributesExtractor()); + PeerServiceAttributesOnStartExtractor + peerServiceAttributesExtractor = + PeerServiceAttributesOnStartExtractor.create(new ArmeriaNetAttributesExtractor()); ArmeriaTracing tracing = ArmeriaTracing.newBuilder(GlobalOpenTelemetry.get()) 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 b222d15921b3..ba145fc6ac4f 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 @@ -15,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; public final class AsyncHttpClientSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.async-http-client-1.9"; @@ -38,7 +38,8 @@ public final class AsyncHttpClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } 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 14aaf5af0caa..35c799e0e077 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 @@ -14,7 +14,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnEndExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceResponseAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnEndExtractor; import org.asynchttpclient.Response; public final class AsyncHttpClientSingletons { @@ -39,7 +39,7 @@ public final class AsyncHttpClientSingletons { .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceResponseAttributesExtractor.create(netAttributesExtractor)) + PeerServiceAttributesOnEndExtractor.create(netAttributesExtractor)) .addAttributesExtractor(new AsyncHttpClientAdditionalAttributesExtractor()) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); 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 c1b40e3d86af..dd1fd3c3cda5 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 @@ -10,7 +10,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.javaagent.instrumentation.api.instrumenter.PeerServiceResponseAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnEndExtractor; import org.elasticsearch.client.Response; public final class ElasticsearchRestInstrumenterFactory { @@ -26,8 +26,7 @@ public static Instrumenter create(String instrumentationName) GlobalOpenTelemetry.get(), instrumentationName, spanNameExtractor) .addAttributesExtractor(attributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceResponseAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesOnEndExtractor.create(netAttributesExtractor)) .newInstrumenter(SpanKindExtractor.alwaysClient()); } 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 f9899509b19f..0d57ec920ce3 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 @@ -15,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; public class GoogleHttpClientSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.google-http-client-1.19"; @@ -38,7 +38,8 @@ public class GoogleHttpClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } diff --git a/instrumentation/grpc-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grpc/v1_6/GrpcSingletons.java b/instrumentation/grpc-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grpc/v1_6/GrpcSingletons.java index 2b118ea99bb4..4303ba6f9bff 100644 --- a/instrumentation/grpc-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grpc/v1_6/GrpcSingletons.java +++ b/instrumentation/grpc-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grpc/v1_6/GrpcSingletons.java @@ -15,7 +15,7 @@ import io.opentelemetry.instrumentation.grpc.v1_6.GrpcTracing; import io.opentelemetry.instrumentation.grpc.v1_6.internal.ContextStorageBridge; import io.opentelemetry.instrumentation.grpc.v1_6.internal.GrpcNetAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; // Holds singleton references. public final class GrpcSingletons { @@ -29,8 +29,8 @@ public final class GrpcSingletons { static { boolean experimentalSpanAttributes = Config.get().getBoolean("otel.instrumentation.grpc.experimental-span-attributes", false); - PeerServiceAttributesExtractor peerServiceAttributesExtractor = - PeerServiceAttributesExtractor.create(new GrpcNetAttributesExtractor()); + PeerServiceAttributesOnStartExtractor peerServiceAttributesExtractor = + PeerServiceAttributesOnStartExtractor.create(new GrpcNetAttributesExtractor()); GrpcTracing tracing = GrpcTracing.newBuilder(GlobalOpenTelemetry.get()) 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 dc2491112988..9870225ba308 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,7 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; import java.net.HttpURLConnection; public class HttpUrlConnectionSingletons { @@ -31,7 +31,8 @@ public class HttpUrlConnectionSingletons { spanNameExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) .newClientInstrumenter(SETTER); } 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 3af0c0d2b5a4..6d2d685d0046 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 @@ -12,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; import java.net.http.HttpRequest; import java.net.http.HttpResponse; @@ -36,7 +36,8 @@ public class JdkHttpClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(SETTER); } 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 f0b06adb7af2..ab81b6d67925 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 @@ -15,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; public class JaxRsClientSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jaxrs-client-1.1"; @@ -38,7 +38,8 @@ public class JaxRsClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new InjectAdapter()); } 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 9cd98be86674..4a4481f8b6aa 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 @@ -14,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; import javax.ws.rs.ProcessingException; import javax.ws.rs.client.ClientRequestContext; import javax.ws.rs.client.ClientResponseContext; @@ -47,7 +47,8 @@ public class JaxRsClientSingletons { }) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new InjectAdapter()); } 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 09a879432989..3df69b2c61ec 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 @@ -14,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; import javax.ws.rs.ProcessingException; import javax.ws.rs.core.Response; import org.jboss.resteasy.client.jaxrs.internal.ClientInvocation; @@ -48,7 +48,8 @@ public class ResteasyClientSingletons { }) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new ResteasyInjectAdapter()); } 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 6ce589beb462..f79ef692d298 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 @@ -14,7 +14,7 @@ import io.opentelemetry.instrumentation.jdbc.internal.DbRequest; import io.opentelemetry.instrumentation.jdbc.internal.JdbcAttributesExtractor; import io.opentelemetry.instrumentation.jdbc.internal.JdbcNetAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; public final class JdbcSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jdbc"; @@ -31,7 +31,8 @@ public final class JdbcSingletons { GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanName) .addAttributesExtractor(dbAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) .newInstrumenter(SpanKindExtractor.alwaysClient()); } 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 a512b53480d4..9d71c20bf9f5 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 @@ -11,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; public final class JedisSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jedis-1.4"; @@ -29,7 +29,8 @@ public final class JedisSingletons { GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanName) .addAttributesExtractor(attributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) .newInstrumenter(SpanKindExtractor.alwaysClient()); } 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 cfbce45fbda6..059e00b1e02f 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 @@ -11,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; public final class JedisSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jedis-3.0"; @@ -29,7 +29,8 @@ public final class JedisSingletons { GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanName) .addAttributesExtractor(attributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) .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 ee09856fb565..cac8e7301926 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.jetty.httpclient.v9_2.internal.JettyClientInstrumenterBuilder; import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal.JettyHttpClientNetAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.api.Response; @@ -23,8 +23,8 @@ private JettyHttpClientSingletons() {} JettyClientInstrumenterBuilder builder = new JettyClientInstrumenterBuilder(GlobalOpenTelemetry.get()); - PeerServiceAttributesExtractor peerServiceAttributesExtractor = - PeerServiceAttributesExtractor.create(new JettyHttpClientNetAttributesExtractor()); + PeerServiceAttributesOnStartExtractor peerServiceAttributesExtractor = + PeerServiceAttributesOnStartExtractor.create(new JettyHttpClientNetAttributesExtractor()); INSTRUMENTER = builder.addAttributeExtractor(peerServiceAttributesExtractor).build(); } 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 d1692c27922a..d30f12bfdb20 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 @@ -15,7 +15,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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; public final class LettuceSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.lettuce-4.0"; @@ -45,7 +45,7 @@ public final class LettuceSingletons { GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, redisUri -> "CONNECT") .addAttributesExtractor(connectNetAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesExtractor.create(connectNetAttributesExtractor)) + PeerServiceAttributesOnStartExtractor.create(connectNetAttributesExtractor)) .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/LettuceSingletons.java b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceSingletons.java index b5c73a16ac65..eadccd9117e8 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 @@ -15,7 +15,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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; public final class LettuceSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.lettuce-5.0"; @@ -45,7 +45,7 @@ public final class LettuceSingletons { GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, redisUri -> "CONNECT") .addAttributesExtractor(connectNetAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesExtractor.create(connectNetAttributesExtractor)) + PeerServiceAttributesOnStartExtractor.create(connectNetAttributesExtractor)) .addAttributesExtractor(new LettuceConnectAttributesExtractor()) .newInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java index 4fae889f9609..46498963d834 100644 --- a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java +++ b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java @@ -17,7 +17,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; public final class LibertyDispatcherSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.liberty-dispatcher"; @@ -40,7 +40,8 @@ public final class LibertyDispatcherSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) .addContextCustomizer( (context, request, attributes) -> ServerSpanNaming.init(context, CONTAINER)) .addRequestMetrics(HttpServerMetrics.get()) 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 a1c283ebb005..938104b5102a 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 @@ -20,7 +20,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; public final class OkHttp2Singletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.okhttp-2.2"; @@ -46,7 +46,8 @@ public final class OkHttp2Singletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) .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 5c8a76dc10ba..7018d37f2c4a 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.okhttp.v3_0.OkHttpTracing; import io.opentelemetry.instrumentation.okhttp.v3_0.internal.OkHttpNetAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; 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.newBuilder(GlobalOpenTelemetry.get()) .addAttributesExtractor( - PeerServiceAttributesExtractor.create(new OkHttpNetAttributesExtractor())) + PeerServiceAttributesOnStartExtractor.create(new OkHttpNetAttributesExtractor())) .build() .newInterceptor(); 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 2445751b9305..c869efe97b1f 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 @@ -13,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceResponseAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnEndExtractor; import play.shaded.ahc.org.asynchttpclient.Request; import play.shaded.ahc.org.asynchttpclient.Response; @@ -39,7 +39,7 @@ public class PlayWsClientSingletons { .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceResponseAttributesExtractor.create(netAttributesExtractor)) + PeerServiceAttributesOnEndExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } diff --git a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java index 01022a75b367..c4e6392b5dc7 100644 --- a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java +++ b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java @@ -17,7 +17,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; import io.opentelemetry.instrumentation.api.servlet.MappingResolver; import io.opentelemetry.instrumentation.servlet.ServletAccessor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; import java.util.ArrayList; import java.util.List; import java.util.function.Function; @@ -73,7 +73,8 @@ public Instrumenter, ServletResponseContext> contextCustomizer : diff --git a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java index 62a3695ba0dc..f7c9a83ae486 100644 --- a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java +++ b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java @@ -20,7 +20,7 @@ import io.opentelemetry.instrumentation.api.servlet.AppServerBridge; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; import io.opentelemetry.instrumentation.servlet.ServletAccessor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; import io.opentelemetry.javaagent.instrumentation.servlet.ServletErrorCauseExtractor; import org.apache.coyote.Request; import org.apache.coyote.Response; @@ -50,7 +50,8 @@ public static Instrumenter newInstrumente .setErrorCauseExtractor(new ServletErrorCauseExtractor<>(accessor)) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) .addAttributesExtractor(additionalAttributeExtractor) .addContextCustomizer( (context, request, attributes) -> { diff --git a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java index 1c28a49e6331..172cec6a8a03 100644 --- a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java +++ b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java @@ -19,7 +19,7 @@ import io.opentelemetry.instrumentation.api.servlet.AppServerBridge; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; import io.opentelemetry.javaagent.bootstrap.undertow.UndertowActiveHandlers; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; import io.undertow.server.HttpServerExchange; public final class UndertowSingletons { @@ -43,7 +43,8 @@ public final class UndertowSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) + .addAttributesExtractor( + PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) .addContextCustomizer( (context, request, attributes) -> { context = ServerSpanNaming.init(context, CONTAINER); diff --git a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceResponseAttributesExtractor.java b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractor.java similarity index 81% rename from javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceResponseAttributesExtractor.java rename to javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractor.java index f7f577b5e6a6..70e5d40b23b1 100644 --- a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceResponseAttributesExtractor.java +++ b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractor.java @@ -22,7 +22,7 @@ * otel.instrumentation.common.peer-service-mapping} configuration property. The format used is a * comma-separated list of {@code host=name} pairs. */ -public final class PeerServiceResponseAttributesExtractor +public final class PeerServiceAttributesOnEndExtractor extends AttributesExtractor { private static final Map JAVAAGENT_PEER_SERVICE_MAPPING = Config.get().getMap("otel.instrumentation.common.peer-service-mapping"); @@ -31,7 +31,7 @@ public final class PeerServiceResponseAttributesExtractor private final NetAttributesOnEndExtractor netResponseAttributesExtractor; // visible for tests - PeerServiceResponseAttributesExtractor( + PeerServiceAttributesOnEndExtractor( Map peerServiceMapping, NetAttributesOnEndExtractor netResponseAttributesExtractor) { this.peerServiceMapping = peerServiceMapping; @@ -39,20 +39,17 @@ public final class PeerServiceResponseAttributesExtractor } /** - * Returns a new {@link PeerServiceResponseAttributesExtractor} that will use the passed {@code + * Returns a new {@link PeerServiceAttributesOnEndExtractor} that will use the passed {@code * netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute. */ - public static - PeerServiceResponseAttributesExtractor create( - NetAttributesOnEndExtractor netResponseAttributesExtractor) { - return new PeerServiceResponseAttributesExtractor<>( + public static PeerServiceAttributesOnEndExtractor create( + NetAttributesOnEndExtractor netResponseAttributesExtractor) { + return new PeerServiceAttributesOnEndExtractor<>( JAVAAGENT_PEER_SERVICE_MAPPING, netResponseAttributesExtractor); } @Override - protected void onStart(AttributesBuilder attributes, REQUEST request) { - onEnd(attributes, request, null, null); - } + protected void onStart(AttributesBuilder attributes, REQUEST request) {} @Override protected void onEnd( @@ -60,10 +57,10 @@ protected void onEnd( REQUEST request, @Nullable RESPONSE response, @Nullable Throwable error) { - String peerName = netResponseAttributesExtractor.peerName(response); + String peerName = netResponseAttributesExtractor.peerName(request, response); String peerService = mapToPeerService(peerName); if (peerService == null) { - String peerIp = netResponseAttributesExtractor.peerIp(response); + String peerIp = netResponseAttributesExtractor.peerIp(request, response); peerService = mapToPeerService(peerIp); } if (peerService != null) { diff --git a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractor.java similarity index 88% rename from javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java rename to javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractor.java index c6e46421d87d..0ab4750f1f21 100644 --- a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java +++ b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractor.java @@ -22,7 +22,7 @@ * otel.instrumentation.common.peer-service-mapping} configuration property. The format used is a * comma-separated list of {@code host=name} pairs. */ -public final class PeerServiceAttributesExtractor +public final class PeerServiceAttributesOnStartExtractor extends AttributesExtractor { private static final Map JAVAAGENT_PEER_SERVICE_MAPPING = Config.get().getMap("otel.instrumentation.common.peer-service-mapping"); @@ -31,7 +31,7 @@ public final class PeerServiceAttributesExtractor private final NetAttributesOnStartExtractor netAttributesExtractor; // visible for tests - PeerServiceAttributesExtractor( + PeerServiceAttributesOnStartExtractor( Map peerServiceMapping, NetAttributesOnStartExtractor netAttributesExtractor) { this.peerServiceMapping = peerServiceMapping; @@ -39,12 +39,12 @@ public final class PeerServiceAttributesExtractor } /** - * Returns a new {@link PeerServiceAttributesExtractor} that will use the passed {@code + * Returns a new {@link PeerServiceAttributesOnStartExtractor} that will use the passed {@code * netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute. */ - public static PeerServiceAttributesExtractor create( + public static PeerServiceAttributesOnStartExtractor create( NetAttributesOnStartExtractor netAttributesExtractor) { - return new PeerServiceAttributesExtractor<>( + return new PeerServiceAttributesOnStartExtractor<>( JAVAAGENT_PEER_SERVICE_MAPPING, netAttributesExtractor); } diff --git a/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractorTest.java b/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractorTest.java similarity index 78% rename from javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractorTest.java rename to javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractorTest.java index dafaf188228b..4c66b637478c 100644 --- a/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractorTest.java +++ b/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractorTest.java @@ -14,7 +14,7 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnEndExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.HashMap; import java.util.Map; @@ -24,16 +24,16 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class PeerServiceAttributesExtractorTest { - @Mock NetAttributesOnStartExtractor netAttributesExtractor; +class PeerServiceAttributesOnEndExtractorTest { + @Mock NetAttributesOnEndExtractor netAttributesExtractor; @Test void shouldNotSetAnyValueIfNetExtractorReturnsNulls() { // given Map peerServiceMapping = singletonMap("1.2.3.4", "myService"); - PeerServiceAttributesExtractor underTest = - new PeerServiceAttributesExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesOnEndExtractor underTest = + new PeerServiceAttributesOnEndExtractor<>(peerServiceMapping, netAttributesExtractor); // when AttributesBuilder attributes = Attributes.builder(); @@ -49,8 +49,8 @@ void shouldNotSetAnyValueIfPeerNameDoesNotMatch() { // given Map peerServiceMapping = singletonMap("example.com", "myService"); - PeerServiceAttributesExtractor underTest = - new PeerServiceAttributesExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesOnEndExtractor underTest = + new PeerServiceAttributesOnEndExtractor<>(peerServiceMapping, netAttributesExtractor); given(netAttributesExtractor.peerName(any(), any())).willReturn("example2.com"); @@ -70,8 +70,8 @@ void shouldNotSetAnyValueIfPeerIpDoesNotMatch() { // given Map peerServiceMapping = singletonMap("1.2.3.4", "myService"); - PeerServiceAttributesExtractor underTest = - new PeerServiceAttributesExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesOnEndExtractor underTest = + new PeerServiceAttributesOnEndExtractor<>(peerServiceMapping, netAttributesExtractor); given(netAttributesExtractor.peerIp(any(), any())).willReturn("1.2.3.5"); @@ -93,8 +93,8 @@ void shouldSetPeerNameIfItMatches() { peerServiceMapping.put("example.com", "myService"); peerServiceMapping.put("1.2.3.4", "someOtherService"); - PeerServiceAttributesExtractor underTest = - new PeerServiceAttributesExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesOnEndExtractor underTest = + new PeerServiceAttributesOnEndExtractor<>(peerServiceMapping, netAttributesExtractor); given(netAttributesExtractor.peerName(any(), any())).willReturn("example.com"); @@ -105,8 +105,7 @@ void shouldSetPeerNameIfItMatches() { underTest.onEnd(endAttributes, "request", "response", null); // then - assertThat(startAttributes.build()) - .containsOnly(entry(SemanticAttributes.PEER_SERVICE, "myService")); + assertThat(startAttributes.build()).isEmpty(); assertThat(endAttributes.build()) .containsOnly(entry(SemanticAttributes.PEER_SERVICE, "myService")); } @@ -118,8 +117,8 @@ void shouldSetPeerIpIfItMatchesAndNameDoesNot() { peerServiceMapping.put("example.com", "myService"); peerServiceMapping.put("1.2.3.4", "someOtherService"); - PeerServiceAttributesExtractor underTest = - new PeerServiceAttributesExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesOnEndExtractor underTest = + new PeerServiceAttributesOnEndExtractor<>(peerServiceMapping, netAttributesExtractor); given(netAttributesExtractor.peerName(any(), any())).willReturn("test.com"); given(netAttributesExtractor.peerIp(any(), any())).willReturn("1.2.3.4"); @@ -131,8 +130,7 @@ void shouldSetPeerIpIfItMatchesAndNameDoesNot() { underTest.onEnd(endAttributes, "request", "response", null); // then - assertThat(startAttributes.build()) - .containsOnly(entry(SemanticAttributes.PEER_SERVICE, "someOtherService")); + assertThat(startAttributes.build()).isEmpty(); assertThat(endAttributes.build()) .containsOnly(entry(SemanticAttributes.PEER_SERVICE, "someOtherService")); } diff --git a/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractorTest.java b/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractorTest.java new file mode 100644 index 000000000000..d22d7b783daf --- /dev/null +++ b/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractorTest.java @@ -0,0 +1,137 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.javaagent.instrumentation.api.instrumenter; + +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; +import static java.util.Collections.singletonMap; +import static org.assertj.core.api.Assertions.entry; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; + +import io.opentelemetry.api.common.Attributes; +import io.opentelemetry.api.common.AttributesBuilder; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class PeerServiceAttributesOnStartExtractorTest { + @Mock NetAttributesOnStartExtractor netAttributesExtractor; + + @Test + void shouldNotSetAnyValueIfNetExtractorReturnsNulls() { + // given + Map peerServiceMapping = singletonMap("1.2.3.4", "myService"); + + PeerServiceAttributesOnStartExtractor underTest = + new PeerServiceAttributesOnStartExtractor<>(peerServiceMapping, netAttributesExtractor); + + // when + AttributesBuilder attributes = Attributes.builder(); + underTest.onStart(attributes, "request"); + underTest.onEnd(attributes, "request", "response", null); + + // then + assertTrue(attributes.build().isEmpty()); + } + + @Test + void shouldNotSetAnyValueIfPeerNameDoesNotMatch() { + // given + Map peerServiceMapping = singletonMap("example.com", "myService"); + + PeerServiceAttributesOnStartExtractor underTest = + new PeerServiceAttributesOnStartExtractor<>(peerServiceMapping, netAttributesExtractor); + + given(netAttributesExtractor.peerName(any())).willReturn("example2.com"); + + // when + AttributesBuilder startAttributes = Attributes.builder(); + underTest.onStart(startAttributes, "request"); + AttributesBuilder endAttributes = Attributes.builder(); + underTest.onEnd(endAttributes, "request", "response", null); + + // then + assertTrue(startAttributes.build().isEmpty()); + assertTrue(endAttributes.build().isEmpty()); + } + + @Test + void shouldNotSetAnyValueIfPeerIpDoesNotMatch() { + // given + Map peerServiceMapping = singletonMap("1.2.3.4", "myService"); + + PeerServiceAttributesOnStartExtractor underTest = + new PeerServiceAttributesOnStartExtractor<>(peerServiceMapping, netAttributesExtractor); + + given(netAttributesExtractor.peerIp(any())).willReturn("1.2.3.5"); + + // when + AttributesBuilder startAttributes = Attributes.builder(); + underTest.onStart(startAttributes, "request"); + AttributesBuilder endAttributes = Attributes.builder(); + underTest.onEnd(endAttributes, "request", "response", null); + + // then + assertTrue(startAttributes.build().isEmpty()); + assertTrue(endAttributes.build().isEmpty()); + } + + @Test + void shouldSetPeerNameIfItMatches() { + // given + Map peerServiceMapping = new HashMap<>(); + peerServiceMapping.put("example.com", "myService"); + peerServiceMapping.put("1.2.3.4", "someOtherService"); + + PeerServiceAttributesOnStartExtractor underTest = + new PeerServiceAttributesOnStartExtractor<>(peerServiceMapping, netAttributesExtractor); + + given(netAttributesExtractor.peerName(any())).willReturn("example.com"); + + // when + AttributesBuilder startAttributes = Attributes.builder(); + underTest.onStart(startAttributes, "request"); + AttributesBuilder endAttributes = Attributes.builder(); + underTest.onEnd(endAttributes, "request", "response", null); + + // then + assertThat(startAttributes.build()) + .containsOnly(entry(SemanticAttributes.PEER_SERVICE, "myService")); + assertThat(endAttributes.build()).isEmpty(); + } + + @Test + void shouldSetPeerIpIfItMatchesAndNameDoesNot() { + // given + Map peerServiceMapping = new HashMap<>(); + peerServiceMapping.put("example.com", "myService"); + peerServiceMapping.put("1.2.3.4", "someOtherService"); + + PeerServiceAttributesOnStartExtractor underTest = + new PeerServiceAttributesOnStartExtractor<>(peerServiceMapping, netAttributesExtractor); + + given(netAttributesExtractor.peerName(any())).willReturn("test.com"); + given(netAttributesExtractor.peerIp(any())).willReturn("1.2.3.4"); + + // when + AttributesBuilder startAttributes = Attributes.builder(); + underTest.onStart(startAttributes, "request"); + AttributesBuilder endAttributes = Attributes.builder(); + underTest.onEnd(endAttributes, "request", "response", null); + + // then + assertThat(startAttributes.build()) + .containsOnly(entry(SemanticAttributes.PEER_SERVICE, "someOtherService")); + assertThat(endAttributes.build()).isEmpty(); + } +} From 9ac7c81d47402415791194aeaa94681b5c7c0982 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Mon, 4 Oct 2021 13:49:20 -0700 Subject: [PATCH 06/26] Fix test --- .../instrumentation/armeria/v1_3/ArmeriaSingletons.java | 7 +++---- .../v1_3/internal/ArmeriaNetAttributesExtractor.java | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java b/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java index 566ca4f96ba0..6600d9b33e88 100644 --- a/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java +++ b/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java @@ -12,7 +12,7 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.armeria.v1_3.ArmeriaTracing; import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaNetAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnEndExtractor; import java.util.function.Function; // Holds singleton references to decorators to match against during suppression. @@ -23,9 +23,8 @@ public final class ArmeriaSingletons { public static final Function SERVER_DECORATOR; static { - PeerServiceAttributesOnStartExtractor - peerServiceAttributesExtractor = - PeerServiceAttributesOnStartExtractor.create(new ArmeriaNetAttributesExtractor()); + PeerServiceAttributesOnEndExtractor peerServiceAttributesExtractor = + PeerServiceAttributesOnEndExtractor.create(new ArmeriaNetAttributesExtractor()); ArmeriaTracing tracing = ArmeriaTracing.newBuilder(GlobalOpenTelemetry.get()) diff --git a/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetAttributesExtractor.java b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetAttributesExtractor.java index 09d4516c4808..346bf4d97562 100644 --- a/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetAttributesExtractor.java +++ b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetAttributesExtractor.java @@ -7,23 +7,23 @@ import com.linecorp.armeria.common.RequestContext; import com.linecorp.armeria.common.logging.RequestLog; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnEndExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import java.net.SocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; public final class ArmeriaNetAttributesExtractor - extends InetSocketAddressNetAttributesOnStartExtractor { + extends InetSocketAddressNetAttributesOnEndExtractor { @Override - public String transport(RequestContext ctx) { + public String transport(RequestContext ctx, @Nullable RequestLog requestLog) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override @Nullable - public InetSocketAddress getAddress(RequestContext ctx) { + public InetSocketAddress getAddress(RequestContext ctx, @Nullable RequestLog requestLog) { SocketAddress address = ctx.remoteAddress(); if (address instanceof InetSocketAddress) { return (InetSocketAddress) address; From ee0c73f7ae1708ee3d6d092475330dd9a745c2ab Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Tue, 5 Oct 2021 11:49:39 -0700 Subject: [PATCH 07/26] Restructure to client/server --- .../opentelemetry/benchmark/InstrumenterBenchmark.java | 4 ++-- .../api/instrumenter/AttributesExtractor.java | 4 ++-- ...InetSocketAddressNetClientAttributesExtractor.java} | 6 +++--- ...InetSocketAddressNetServerAttributesExtractor.java} | 7 +++---- ...xtractor.java => NetAttributesClientExtractor.java} | 4 ++-- ...xtractor.java => NetAttributesServerExtractor.java} | 4 ++-- .../api/instrumenter/InstrumenterTest.java | 6 +++--- ...SocketAddressNetClientAttributesExtractorTest.java} | 7 ++++--- ...SocketAddressNetServerAttributesExtractorTest.java} | 6 +++--- ...Test.java => NetAttributesClientExtractorTest.java} | 10 +++++----- ...Test.java => NetAttributesServerExtractorTest.java} | 10 +++++----- .../v2_7/internal/DubboNetAttributesExtractor.java | 4 ++-- .../ApacheHttpAsyncClientNetAttributesExtractor.java | 4 ++-- .../v2_0/ApacheHttpClientNetAttributesExtractor.java | 4 ++-- .../v4_0/ApacheHttpClientNetAttributesExtractor.java | 4 ++-- .../v4_3/ApacheHttpClientNetAttributesExtractor.java | 4 ++-- .../v5_0/ApacheHttpClientNetAttributesExtractor.java | 4 ++-- .../v1_3/internal/ArmeriaNetAttributesExtractor.java | 4 ++-- .../v1_9/AsyncHttpClientNetAttributesExtractor.java | 4 ++-- .../v2_0/AsyncHttpClientNetAttributesExtractor.java | 4 ++-- .../v2_0/AsyncHttpClientSingletons.java | 4 ++-- .../v3_0/CassandraNetAttributesExtractor.java | 4 ++-- .../v4_0/CassandraNetAttributesExtractor.java | 4 ++-- ...lasticsearchRestNetResponseAttributesExtractor.java | 4 ++-- .../Elasticsearch6TransportNetAttributesExtractor.java | 4 ++-- ...ElasticTransportNetResponseAttributesExtractor.java | 4 ++-- .../GoogleHttpClientNetAttributesExtractor.java | 4 ++-- .../grpc/v1_6/internal/GrpcNetAttributesExtractor.java | 4 ++-- .../HttpUrlNetAttributesExtractor.java | 4 ++-- .../httpclient/JdkHttpNetAttributesExtractor.java | 4 ++-- .../v1_1/JaxRsClientNetAttributesExtractor.java | 4 ++-- .../v2_0/JaxRsClientNetAttributesExtractor.java | 4 ++-- .../v2_0/ResteasyClientNetAttributesExtractor.java | 4 ++-- .../jdbc/internal/JdbcNetAttributesExtractor.java | 4 ++-- .../jedis/v1_4/JedisNetAttributesExtractor.java | 4 ++-- .../jedis/v3_0/JedisNetAttributesExtractor.java | 4 ++-- .../JettyHttpClientNetAttributesExtractor.java | 4 ++-- .../KubernetesNetAttributesExtractor.java | 4 ++-- .../v4_0/LettuceConnectNetAttributesExtractor.java | 4 ++-- .../v5_0/LettuceConnectNetAttributesExtractor.java | 4 ++-- .../LibertyDispatcherNetAttributesExtractor.java | 4 ++-- .../dispatcher/LibertyDispatcherSingletons.java | 4 ++-- .../okhttp/v2_2/OkHttp2NetAttributesExtractor.java | 4 ++-- .../instrumentation/okhttp/v2_2/OkHttp2Singletons.java | 4 ++-- .../v3_0/internal/OkHttpNetAttributesExtractor.java | 4 ++-- .../playws/PlayWsClientNetAttributesExtractor.java | 4 ++-- .../internal/RatpackNetAttributesExtractor.java | 4 ++-- .../redisson/RedissonNetAttributesExtractor.java | 4 ++-- .../restlet/v1_0/RestletNetAttributesExtractor.java | 4 ++-- .../restlet/v1_0/RestletTracingBuilder.java | 4 ++-- .../spring/web/SpringWebNetAttributesExtractor.java | 4 ++-- .../webmvc/SpringWebMvcNetAttributesExtractor.java | 4 ++-- .../tomcat/common/TomcatInstrumenterBuilder.java | 4 ++-- .../tomcat/common/TomcatNetAttributesExtractor.java | 4 ++-- .../undertow/UndertowNetAttributesExtractor.java | 4 ++-- .../instrumentation/undertow/UndertowSingletons.java | 4 ++-- .../PeerServiceAttributesOnEndExtractor.java | 8 ++++---- .../PeerServiceAttributesOnStartExtractor.java | 8 ++++---- .../PeerServiceAttributesOnEndExtractorTest.java | 4 ++-- .../PeerServiceAttributesOnStartExtractorTest.java | 4 ++-- 60 files changed, 136 insertions(+), 136 deletions(-) rename instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/{InetSocketAddressNetAttributesOnEndExtractor.java => InetSocketAddressNetClientAttributesExtractor.java} (88%) rename instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/{InetSocketAddressNetAttributesOnStartExtractor.java => InetSocketAddressNetServerAttributesExtractor.java} (87%) rename instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/{NetAttributesOnEndExtractor.java => NetAttributesClientExtractor.java} (92%) rename instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/{NetAttributesOnStartExtractor.java => NetAttributesServerExtractor.java} (94%) rename instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/{InetSocketAddressNetAttributesOnEndExtractorTest.java => InetSocketAddressNetClientAttributesExtractorTest.java} (90%) rename instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/{InetSocketAddressNetAttributesOnStartExtractorTest.java => InetSocketAddressNetServerAttributesExtractorTest.java} (92%) rename instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/{NetAttributesOnEndExtractorTest.java => NetAttributesClientExtractorTest.java} (89%) rename instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/{NetAttributesOnStartExtractorTest.java => NetAttributesServerExtractorTest.java} (86%) diff --git a/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java b/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java index 063f2c66dd4b..633157993bc5 100644 --- a/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java +++ b/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java @@ -11,7 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.CapturedHttpHeaders; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import java.util.Collections; @@ -120,7 +120,7 @@ protected List responseHeader(Void unused, Void unused2, String name) { } static class ConstantNetAttributesExtractor - extends InetSocketAddressNetAttributesOnStartExtractor { + extends InetSocketAddressNetServerAttributesExtractor { private static final InetSocketAddress ADDRESS = InetSocketAddress.createUnresolved("localhost", 8080); diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java index d5cec3455118..895099af0aec 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java @@ -9,7 +9,7 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.instrumentation.api.instrumenter.db.DbAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import org.checkerframework.checker.nullness.qual.Nullable; /** @@ -22,7 +22,7 @@ * * @see DbAttributesExtractor * @see HttpClientAttributesExtractor - * @see NetAttributesOnStartExtractor + * @see NetAttributesServerExtractor */ public abstract class AttributesExtractor { /** diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnEndExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesExtractor.java similarity index 88% rename from instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnEndExtractor.java rename to instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesExtractor.java index 8bfa618987e0..3451e3b0dd2d 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnEndExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesExtractor.java @@ -14,10 +14,10 @@ * href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/span-general.md#general-network-connection-attributes">Network * attributes from a {@link InetSocketAddress}. Most network libraries will provide access to a * {@link InetSocketAddress} so this is a convenient alternative to {@link - * NetAttributesOnEndExtractor}. There is no meaning to implement both in the same instrumentation. + * NetAttributesClientExtractor}. There is no meaning to implement both in the same instrumentation. */ -public abstract class InetSocketAddressNetAttributesOnEndExtractor - extends NetAttributesOnEndExtractor { +public abstract class InetSocketAddressNetClientAttributesExtractor + extends NetAttributesClientExtractor { /** * This method will be called twice: both when the request starts ({@code response} is always null diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnStartExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesExtractor.java similarity index 87% rename from instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnStartExtractor.java rename to instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesExtractor.java index 243c20f647dd..e1b959730654 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnStartExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesExtractor.java @@ -14,11 +14,10 @@ * href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/span-general.md#general-network-connection-attributes">Network * attributes from a {@link InetSocketAddress}. Most network libraries will provide access to a * {@link InetSocketAddress} so this is a convenient alternative to {@link - * NetAttributesOnStartExtractor}. There is no meaning to implement both in the same - * instrumentation. + * NetAttributesServerExtractor}. There is no meaning to implement both in the same instrumentation. */ -public abstract class InetSocketAddressNetAttributesOnStartExtractor - extends NetAttributesOnStartExtractor { +public abstract class InetSocketAddressNetServerAttributesExtractor + extends NetAttributesServerExtractor { /** * This method will be called twice: both when the request starts ({@code response} is always null diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnEndExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractor.java similarity index 92% rename from instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnEndExtractor.java rename to instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractor.java index 31c9ae2acb65..cf0a5316d598 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnEndExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractor.java @@ -14,9 +14,9 @@ * 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 InetSocketAddressNetAttributesOnEndExtractor}. + * it is more convenient to use {@link InetSocketAddressNetClientAttributesExtractor}. */ -public abstract class NetAttributesOnEndExtractor +public abstract class NetAttributesClientExtractor extends AttributesExtractor { @Override diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnStartExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractor.java similarity index 94% rename from instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnStartExtractor.java rename to instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractor.java index 136a94ae7bec..37fb893f6bad 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnStartExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractor.java @@ -14,9 +14,9 @@ * 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 InetSocketAddressNetAttributesOnStartExtractor}. + * it is more convenient to use {@link InetSocketAddressNetServerAttributesExtractor}. */ -public abstract class NetAttributesOnStartExtractor +public abstract class NetAttributesServerExtractor extends AttributesExtractor { @Override diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterTest.java index a31c68c184ef..09acd77f87be 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterTest.java @@ -27,7 +27,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.messaging.MessageOperation; import io.opentelemetry.instrumentation.api.instrumenter.messaging.MessagingAttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.instrumentation.api.instrumenter.rpc.RpcAttributesExtractor; import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; import io.opentelemetry.sdk.testing.junit5.OpenTelemetryExtension; @@ -155,7 +155,7 @@ public String get(Map carrier, String key) { MessagingAttributesExtractor, Map> mockMessagingAttributes; @Mock RpcAttributesExtractor, Map> mockRpcAttributes; - @Mock NetAttributesOnStartExtractor, Map> mockNetAttributes; + @Mock NetAttributesServerExtractor, Map> mockNetAttributes; @Test void server() { @@ -924,7 +924,7 @@ private static LinkData expectedSpanLink() { } private static final class ConstantNetPeerIpExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { private final String peerIp; diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnEndExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesExtractorTest.java similarity index 90% rename from instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnEndExtractorTest.java rename to instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesExtractorTest.java index 6750b5c345a5..73b0ec121748 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnEndExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesExtractorTest.java @@ -17,11 +17,12 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class InetSocketAddressNetAttributesOnEndExtractorTest { +class InetSocketAddressNetClientAttributesExtractorTest { - private final InetSocketAddressNetAttributesOnEndExtractor + private final InetSocketAddressNetClientAttributesExtractor extractor = - new InetSocketAddressNetAttributesOnEndExtractor() { + new InetSocketAddressNetClientAttributesExtractor< + InetSocketAddress, InetSocketAddress>() { @Override public InetSocketAddress getAddress( InetSocketAddress request, InetSocketAddress response) { diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnStartExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesExtractorTest.java similarity index 92% rename from instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnStartExtractorTest.java rename to instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesExtractorTest.java index 22d5206783b8..3a775e35ccb0 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesOnStartExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesExtractorTest.java @@ -17,11 +17,11 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class InetSocketAddressNetAttributesOnStartExtractorTest { +class InetSocketAddressNetServerAttributesExtractorTest { - private final InetSocketAddressNetAttributesOnStartExtractor + private final InetSocketAddressNetServerAttributesExtractor extractor = - new InetSocketAddressNetAttributesOnStartExtractor< + new InetSocketAddressNetServerAttributesExtractor< InetSocketAddress, InetSocketAddress>() { @Override public InetSocketAddress getAddress(InetSocketAddress request) { diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnEndExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractorTest.java similarity index 89% rename from instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnEndExtractorTest.java rename to instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractorTest.java index d95a286fb8fd..ea7ec066b75b 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnEndExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractorTest.java @@ -15,10 +15,10 @@ import java.util.Map; import org.junit.jupiter.api.Test; -class NetAttributesOnEndExtractorTest { +class NetAttributesClientExtractorTest { - static class TestNetAttributesOnEndExtractor - extends NetAttributesOnEndExtractor, Map> { + static class TestNetAttributesClientExtractor + extends NetAttributesClientExtractor, Map> { @Override public String transport(Map request, Map response) { @@ -64,7 +64,7 @@ void normal() { response.put("peerPort", "42"); response.put("peerIp", "4.3.2.1"); - TestNetAttributesOnEndExtractor extractor = new TestNetAttributesOnEndExtractor(); + TestNetAttributesClientExtractor extractor = new TestNetAttributesClientExtractor(); // when AttributesBuilder endAttributes = Attributes.builder(); @@ -92,7 +92,7 @@ public void doesNotSetDuplicateAttributes() { response.put("peerPort", "42"); response.put("peerIp", "4.3.2.1"); - TestNetAttributesOnEndExtractor extractor = new TestNetAttributesOnEndExtractor(); + TestNetAttributesClientExtractor extractor = new TestNetAttributesClientExtractor(); // when AttributesBuilder endAttributes = Attributes.builder(); diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnStartExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractorTest.java similarity index 86% rename from instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnStartExtractorTest.java rename to instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractorTest.java index f5ac7cb6f7d2..7b091634fd13 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesOnStartExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractorTest.java @@ -15,10 +15,10 @@ import java.util.Map; import org.junit.jupiter.api.Test; -class NetAttributesOnStartExtractorTest { +class NetAttributesServerExtractorTest { - static class TestNetAttributesOnStartExtractor - extends NetAttributesOnStartExtractor, Map> { + static class TestNetAttributesServerExtractor + extends NetAttributesServerExtractor, Map> { @Override public String transport(Map request) { @@ -50,7 +50,7 @@ void normal() { request.put("peerPort", "123"); request.put("peerIp", "1.2.3.4"); - TestNetAttributesOnStartExtractor extractor = new TestNetAttributesOnStartExtractor(); + TestNetAttributesServerExtractor extractor = new TestNetAttributesServerExtractor(); // when AttributesBuilder startAttributes = Attributes.builder(); @@ -74,7 +74,7 @@ public void doesNotSetDuplicateAttributes() { request.put("peerIp", "1.2.3.4"); request.put("peerPort", "123"); - TestNetAttributesOnStartExtractor extractor = new TestNetAttributesOnStartExtractor(); + TestNetAttributesServerExtractor extractor = new TestNetAttributesServerExtractor(); // when AttributesBuilder startAttributes = Attributes.builder(); diff --git a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetAttributesExtractor.java b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetAttributesExtractor.java index 1730385ec954..0ff9e6d1feb8 100644 --- a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetAttributesExtractor.java +++ b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetAttributesExtractor.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.InetSocketAddressNetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor; import java.net.InetSocketAddress; import org.apache.dubbo.rpc.Result; import org.checkerframework.checker.nullness.qual.Nullable; public final class DubboNetAttributesExtractor - extends InetSocketAddressNetAttributesOnStartExtractor { + extends InetSocketAddressNetServerAttributesExtractor { @Override public @Nullable InetSocketAddress getAddress(DubboRequest request) { 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/ApacheHttpAsyncClientNetAttributesExtractor.java index e6a1b637dead..8f234da50481 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/ApacheHttpAsyncClientNetAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpasyncclient; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.http.HttpResponse; import org.checkerframework.checker.nullness.qual.Nullable; final class ApacheHttpAsyncClientNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Override public String transport(ApacheHttpClientRequest request) { 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/ApacheHttpClientNetAttributesExtractor.java index 5f895ac2f46f..49faf8d124e3 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/ApacheHttpClientNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.commons.httpclient.HostConfiguration; import org.apache.commons.httpclient.HttpMethod; import org.checkerframework.checker.nullness.qual.Nullable; final class ApacheHttpClientNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Override public String transport(HttpMethod request) { 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/ApacheHttpClientNetAttributesExtractor.java index 2b3e17a73be9..32de57a6b318 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/ApacheHttpClientNetAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v4_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.http.HttpResponse; import org.checkerframework.checker.nullness.qual.Nullable; final class ApacheHttpClientNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Override public String transport(ApacheHttpClientRequest request) { 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/ApacheHttpClientNetAttributesExtractor.java index 90145f3d1a5f..86085eadb1f9 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/ApacheHttpClientNetAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.instrumentation.apachehttpclient.v4_3; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.http.HttpResponse; import org.checkerframework.checker.nullness.qual.Nullable; final class ApacheHttpClientNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Override public String transport(ApacheHttpClientRequest request) { 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/ApacheHttpClientNetAttributesExtractor.java index 1eb08e2e7bc3..ba3c1420bb1d 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/ApacheHttpClientNetAttributesExtractor.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v5_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.HttpResponse; @@ -14,7 +14,7 @@ import org.slf4j.LoggerFactory; final class ApacheHttpClientNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { private static final Logger logger = LoggerFactory.getLogger(ApacheHttpClientNetAttributesExtractor.class); diff --git a/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetAttributesExtractor.java b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetAttributesExtractor.java index 346bf4d97562..8faec062323c 100644 --- a/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetAttributesExtractor.java +++ b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetAttributesExtractor.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.InetSocketAddressNetAttributesOnEndExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import java.net.SocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; public final class ArmeriaNetAttributesExtractor - extends InetSocketAddressNetAttributesOnEndExtractor { + extends InetSocketAddressNetClientAttributesExtractor { @Override public String transport(RequestContext ctx, @Nullable RequestLog requestLog) { 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/AsyncHttpClientNetAttributesExtractor.java index 7b2d0de0b385..35f3b6d4f8b5 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/AsyncHttpClientNetAttributesExtractor.java @@ -7,12 +7,12 @@ import com.ning.http.client.Request; import com.ning.http.client.Response; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; final class AsyncHttpClientNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Override public String transport(Request request) { 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/AsyncHttpClientNetAttributesExtractor.java index 212d1908baca..2112422c20c5 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/AsyncHttpClientNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.asynchttpclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnEndExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import org.asynchttpclient.Response; import org.checkerframework.checker.nullness.qual.Nullable; final class AsyncHttpClientNetAttributesExtractor - extends InetSocketAddressNetAttributesOnEndExtractor { + extends InetSocketAddressNetClientAttributesExtractor { @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 35c799e0e077..c4cf016aa5da 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 @@ -13,7 +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.NetAttributesOnEndExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnEndExtractor; import org.asynchttpclient.Response; @@ -29,7 +29,7 @@ public final class AsyncHttpClientSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetAttributesOnEndExtractor netAttributesExtractor = + NetAttributesClientExtractor netAttributesExtractor = new AsyncHttpClientNetAttributesExtractor(); INSTRUMENTER = 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/CassandraNetAttributesExtractor.java index 629c52b0cfdd..d3b3d22a0ec9 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/CassandraNetAttributesExtractor.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.InetSocketAddressNetAttributesOnEndExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; final class CassandraNetAttributesExtractor - extends InetSocketAddressNetAttributesOnEndExtractor { + extends InetSocketAddressNetClientAttributesExtractor { @Override @Nullable 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/CassandraNetAttributesExtractor.java index b9d288e890f9..89accdb0c179 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/CassandraNetAttributesExtractor.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.InetSocketAddressNetAttributesOnEndExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; import java.net.InetSocketAddress; import java.net.SocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; final class CassandraNetAttributesExtractor - extends InetSocketAddressNetAttributesOnEndExtractor { + extends InetSocketAddressNetClientAttributesExtractor { @Override @Nullable 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/ElasticsearchRestNetResponseAttributesExtractor.java index 6bde0840a5b4..deb2b9a06308 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/ElasticsearchRestNetResponseAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.rest; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnEndExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; import org.elasticsearch.client.Response; final class ElasticsearchRestNetResponseAttributesExtractor - extends NetAttributesOnEndExtractor { + extends NetAttributesClientExtractor { @Override public String transport(String operation, Response response) { return SemanticAttributes.NetTransportValues.IP_TCP; 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/Elasticsearch6TransportNetAttributesExtractor.java index 92da5b36b105..393d2ff4e963 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/Elasticsearch6TransportNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.v6_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnEndExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportRequest; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; import org.elasticsearch.action.ActionResponse; public class Elasticsearch6TransportNetAttributesExtractor - extends InetSocketAddressNetAttributesOnEndExtractor { + extends InetSocketAddressNetClientAttributesExtractor { @Override public @Nullable String transport( ElasticTransportRequest request, @Nullable ActionResponse response) { 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/ElasticTransportNetResponseAttributesExtractor.java index ad219a533337..a2efc0642795 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/ElasticTransportNetResponseAttributesExtractor.java @@ -5,12 +5,12 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnEndExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; import org.checkerframework.checker.nullness.qual.Nullable; import org.elasticsearch.action.ActionResponse; public class ElasticTransportNetResponseAttributesExtractor - extends NetAttributesOnEndExtractor { + extends NetAttributesClientExtractor { @Override public @Nullable 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/GoogleHttpClientNetAttributesExtractor.java index eb1a5f482c3f..fadb23ca8be1 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/GoogleHttpClientNetAttributesExtractor.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.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; final class GoogleHttpClientNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Override public String transport(HttpRequest request) { diff --git a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetAttributesExtractor.java b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetAttributesExtractor.java index de58c0410841..73ba5fa3bf43 100644 --- a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetAttributesExtractor.java +++ b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetAttributesExtractor.java @@ -6,7 +6,7 @@ package io.opentelemetry.instrumentation.grpc.v1_6.internal; import io.grpc.Status; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor; import io.opentelemetry.instrumentation.grpc.v1_6.GrpcRequest; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; @@ -14,7 +14,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; public final class GrpcNetAttributesExtractor - extends InetSocketAddressNetAttributesOnStartExtractor { + extends InetSocketAddressNetServerAttributesExtractor { @Override @Nullable public InetSocketAddress getAddress(GrpcRequest request) { 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/HttpUrlNetAttributesExtractor.java index cd79acd02eeb..71b21380c064 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/HttpUrlNetAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.httpurlconnection; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.HttpURLConnection; import org.checkerframework.checker.nullness.qual.Nullable; class HttpUrlNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Override public @Nullable String transport(HttpURLConnection connection) { return SemanticAttributes.NetTransportValues.IP_TCP; 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/JdkHttpNetAttributesExtractor.java index b8bfcf3c1e07..cfbd9d20313b 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/JdkHttpNetAttributesExtractor.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.httpclient; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.http.HttpRequest; import java.net.http.HttpResponse; @@ -14,7 +14,7 @@ import org.slf4j.LoggerFactory; public class JdkHttpNetAttributesExtractor - extends NetAttributesOnStartExtractor> { + extends NetAttributesServerExtractor> { private static final Logger logger = LoggerFactory.getLogger(JdkHttpNetAttributesExtractor.class); 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/JaxRsClientNetAttributesExtractor.java index d0a5b61b7570..6d323194a558 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/JaxRsClientNetAttributesExtractor.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.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; final class JaxRsClientNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Override public String transport(ClientRequest request) { 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/JaxRsClientNetAttributesExtractor.java index ed05290526c5..2c4ec0713501 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/JaxRsClientNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.jaxrsclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.ws.rs.client.ClientRequestContext; import javax.ws.rs.client.ClientResponseContext; import org.checkerframework.checker.nullness.qual.Nullable; final class JaxRsClientNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Override public String transport(ClientRequestContext request) { 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/ResteasyClientNetAttributesExtractor.java index d6f86efc2f8f..d7c355f991f9 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/ResteasyClientNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.jaxrsclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.ws.rs.core.Response; import org.checkerframework.checker.nullness.qual.Nullable; import org.jboss.resteasy.client.jaxrs.internal.ClientInvocation; final class ResteasyClientNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Override public String transport(ClientInvocation request) { 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/JdbcNetAttributesExtractor.java index 1692516b8d09..fde76e11a439 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/JdbcNetAttributesExtractor.java @@ -5,11 +5,11 @@ package io.opentelemetry.instrumentation.jdbc.internal; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import org.checkerframework.checker.nullness.qual.Nullable; public final class JdbcNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Nullable @Override 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/JedisNetAttributesExtractor.java index 4a13e066791c..2c5bd09b82d8 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/JedisNetAttributesExtractor.java @@ -5,10 +5,10 @@ package io.opentelemetry.javaagent.instrumentation.jedis.v1_4; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import org.checkerframework.checker.nullness.qual.Nullable; -final class JedisNetAttributesExtractor extends NetAttributesOnStartExtractor { +final class JedisNetAttributesExtractor extends NetAttributesServerExtractor { @Override @Nullable 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/JedisNetAttributesExtractor.java index 656347022b67..5301c6c8c680 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/JedisNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.jedis.v3_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import java.net.Socket; import org.checkerframework.checker.nullness.qual.Nullable; final class JedisNetAttributesExtractor - extends InetSocketAddressNetAttributesOnStartExtractor { + extends InetSocketAddressNetServerAttributesExtractor { @Override public @Nullable InetSocketAddress getAddress(JedisRequest jedisRequest) { 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/JettyHttpClientNetAttributesExtractor.java index 148ab6746f54..ab9d345485ce 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/JettyHttpClientNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.api.Response; public class JettyHttpClientNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Override public String transport(Request request) { 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/KubernetesNetAttributesExtractor.java index 26f2b72da18e..a1d6d0da77d1 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/KubernetesNetAttributesExtractor.java @@ -6,13 +6,13 @@ package io.opentelemetry.javaagent.instrumentation.kubernetesclient; import io.kubernetes.client.openapi.ApiResponse; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import okhttp3.Request; import org.checkerframework.checker.nullness.qual.Nullable; class KubernetesNetAttributesExtractor - extends NetAttributesOnStartExtractor> { + extends NetAttributesServerExtractor> { @Override public String transport(Request request) { 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/LettuceConnectNetAttributesExtractor.java index e6724de16d90..72b51591c97e 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/LettuceConnectNetAttributesExtractor.java @@ -6,11 +6,11 @@ package io.opentelemetry.javaagent.instrumentation.lettuce.v4_0; import com.lambdaworks.redis.RedisURI; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import org.checkerframework.checker.nullness.qual.Nullable; final class LettuceConnectNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Override @Nullable 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/LettuceConnectNetAttributesExtractor.java index c1b1dbb07b2f..140788943b47 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/LettuceConnectNetAttributesExtractor.java @@ -6,11 +6,11 @@ package io.opentelemetry.javaagent.instrumentation.lettuce.v5_0; import io.lettuce.core.RedisURI; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import org.checkerframework.checker.nullness.qual.Nullable; final class LettuceConnectNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Override @Nullable diff --git a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesExtractor.java b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesExtractor.java index d016acb1a9af..4ff1068ecdc6 100644 --- a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesExtractor.java +++ b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesExtractor.java @@ -5,12 +5,12 @@ package io.opentelemetry.javaagent.instrumentation.liberty.dispatcher; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; public class LibertyDispatcherNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Override public String transport(LibertyRequest libertyRequest) { diff --git a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java index 46498963d834..d42c1c4f33ba 100644 --- a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java +++ b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java @@ -15,7 +15,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.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; @@ -31,7 +31,7 @@ public final class LibertyDispatcherSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetAttributesOnStartExtractor netAttributesExtractor = + NetAttributesServerExtractor netAttributesExtractor = new LibertyDispatcherNetAttributesExtractor(); INSTRUMENTER = 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/OkHttp2NetAttributesExtractor.java index 5ab37e39d9e6..59fbdc45dc58 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/OkHttp2NetAttributesExtractor.java @@ -7,12 +7,12 @@ import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; public final class OkHttp2NetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Override public String transport(Request request) { 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 938104b5102a..f4add5d8c1e3 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 @@ -19,7 +19,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.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; public final class OkHttp2Singletons { @@ -35,7 +35,7 @@ public final class OkHttp2Singletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetAttributesOnStartExtractor netAttributesExtractor = + NetAttributesServerExtractor netAttributesExtractor = new OkHttp2NetAttributesExtractor(); OpenTelemetry openTelemetry = GlobalOpenTelemetry.get(); 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/OkHttpNetAttributesExtractor.java index c9f836eb5157..9ba1781181b5 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/OkHttpNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.instrumentation.okhttp.v3_0.internal; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import okhttp3.Request; import okhttp3.Response; import org.checkerframework.checker.nullness.qual.Nullable; public final class OkHttpNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Override public String transport(Request request) { 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/PlayWsClientNetAttributesExtractor.java index 5e741ec22cf3..832da2e0897d 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/PlayWsClientNetAttributesExtractor.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.playws; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnEndExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; @@ -13,7 +13,7 @@ import play.shaded.ahc.org.asynchttpclient.Response; final class PlayWsClientNetAttributesExtractor - extends InetSocketAddressNetAttributesOnEndExtractor { + extends InetSocketAddressNetClientAttributesExtractor { @Override public String transport(Request request, @Nullable Response response) { diff --git a/instrumentation/ratpack-1.4/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesExtractor.java b/instrumentation/ratpack-1.4/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesExtractor.java index 6cf4b37ec65c..8fe080d886db 100644 --- a/instrumentation/ratpack-1.4/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesExtractor.java +++ b/instrumentation/ratpack-1.4/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.instrumentation.ratpack.internal; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; import ratpack.http.Request; import ratpack.http.Response; public final class RatpackNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Override @Nullable public String transport(Request request) { 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/RedissonNetAttributesExtractor.java index 6d88379f9ada..a33b35bc3a5f 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/RedissonNetAttributesExtractor.java @@ -5,12 +5,12 @@ package io.opentelemetry.javaagent.instrumentation.redisson; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; final class RedissonNetAttributesExtractor - extends InetSocketAddressNetAttributesOnStartExtractor { + extends InetSocketAddressNetServerAttributesExtractor { @Override public InetSocketAddress getAddress(RedissonRequest request) { diff --git a/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesExtractor.java b/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesExtractor.java index aa4cfbe6cce3..5d4922acf606 100644 --- a/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesExtractor.java +++ b/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.instrumentation.restlet.v1_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; import org.restlet.data.Request; import org.restlet.data.Response; -final class RestletNetAttributesExtractor extends NetAttributesOnStartExtractor { +final class RestletNetAttributesExtractor extends NetAttributesServerExtractor { @Override public String transport(Request request) { return SemanticAttributes.NetTransportValues.IP_TCP; diff --git a/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletTracingBuilder.java b/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletTracingBuilder.java index 43d4f0f868be..05ece6bc5335 100644 --- a/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletTracingBuilder.java +++ b/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletTracingBuilder.java @@ -12,7 +12,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import java.util.ArrayList; import java.util.List; import org.restlet.data.Request; @@ -50,7 +50,7 @@ public RestletTracing build() { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetAttributesOnStartExtractor netAttributesExtractor = + NetAttributesServerExtractor netAttributesExtractor = new RestletNetAttributesExtractor(); Instrumenter instrumenter = diff --git a/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesExtractor.java b/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesExtractor.java index d8a8f8345723..5a401baf43d8 100644 --- a/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesExtractor.java +++ b/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.instrumentation.spring.web; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; import org.springframework.http.HttpRequest; import org.springframework.http.client.ClientHttpResponse; final class SpringWebNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Override public String transport(HttpRequest httpRequest) { return SemanticAttributes.NetTransportValues.IP_TCP; diff --git a/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesExtractor.java b/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesExtractor.java index f0e333701dd1..e3b89a32d2e7 100644 --- a/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesExtractor.java +++ b/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.instrumentation.spring.webmvc; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.checkerframework.checker.nullness.qual.Nullable; final class SpringWebMvcNetAttributesExtractor - extends NetAttributesOnStartExtractor { + extends NetAttributesServerExtractor { @Override public String transport(HttpServletRequest request) { return SemanticAttributes.NetTransportValues.IP_TCP; diff --git a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java index f7c9a83ae486..19c34afae421 100644 --- a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java +++ b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java @@ -16,7 +16,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.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.instrumentation.api.servlet.AppServerBridge; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; import io.opentelemetry.instrumentation.servlet.ServletAccessor; @@ -39,7 +39,7 @@ public static Instrumenter newInstrumente HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetAttributesOnStartExtractor netAttributesExtractor = + NetAttributesServerExtractor netAttributesExtractor = new TomcatNetAttributesExtractor(); AttributesExtractor additionalAttributeExtractor = new TomcatAdditionalAttributesExtractor<>(accessor, servletEntityProvider); diff --git a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesExtractor.java b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesExtractor.java index cc9b8b583f84..02bdb86aaae6 100644 --- a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesExtractor.java +++ b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.tomcat.common; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import org.apache.coyote.ActionCode; import org.apache.coyote.Request; import org.apache.coyote.Response; import org.checkerframework.checker.nullness.qual.Nullable; -public class TomcatNetAttributesExtractor extends NetAttributesOnStartExtractor { +public class TomcatNetAttributesExtractor extends NetAttributesServerExtractor { @Override public @Nullable String transport(Request request) { diff --git a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowNetAttributesExtractor.java b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowNetAttributesExtractor.java index 26ce41de4ec1..ac278775732e 100644 --- a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowNetAttributesExtractor.java +++ b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.undertow; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import io.undertow.server.HttpServerExchange; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; public class UndertowNetAttributesExtractor - extends InetSocketAddressNetAttributesOnStartExtractor { + extends InetSocketAddressNetServerAttributesExtractor { @Override public @Nullable InetSocketAddress getAddress(HttpServerExchange exchange) { diff --git a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java index 172cec6a8a03..dfd7cfe22f50 100644 --- a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java +++ b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java @@ -15,7 +15,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.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.instrumentation.api.servlet.AppServerBridge; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; import io.opentelemetry.javaagent.bootstrap.undertow.UndertowActiveHandlers; @@ -34,7 +34,7 @@ public final class UndertowSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetAttributesOnStartExtractor netAttributesExtractor = + NetAttributesServerExtractor netAttributesExtractor = new UndertowNetAttributesExtractor(); INSTRUMENTER = diff --git a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractor.java b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractor.java index 70e5d40b23b1..a9cdc686ac71 100644 --- a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractor.java +++ b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractor.java @@ -8,7 +8,7 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.instrumentation.api.config.Config; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnEndExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.Map; import org.checkerframework.checker.nullness.qual.Nullable; @@ -28,12 +28,12 @@ public final class PeerServiceAttributesOnEndExtractor Config.get().getMap("otel.instrumentation.common.peer-service-mapping"); private final Map peerServiceMapping; - private final NetAttributesOnEndExtractor netResponseAttributesExtractor; + private final NetAttributesClientExtractor netResponseAttributesExtractor; // visible for tests PeerServiceAttributesOnEndExtractor( Map peerServiceMapping, - NetAttributesOnEndExtractor netResponseAttributesExtractor) { + NetAttributesClientExtractor netResponseAttributesExtractor) { this.peerServiceMapping = peerServiceMapping; this.netResponseAttributesExtractor = netResponseAttributesExtractor; } @@ -43,7 +43,7 @@ public final class PeerServiceAttributesOnEndExtractor * netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute. */ public static PeerServiceAttributesOnEndExtractor create( - NetAttributesOnEndExtractor netResponseAttributesExtractor) { + NetAttributesClientExtractor netResponseAttributesExtractor) { return new PeerServiceAttributesOnEndExtractor<>( JAVAAGENT_PEER_SERVICE_MAPPING, netResponseAttributesExtractor); } diff --git a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractor.java b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractor.java index 0ab4750f1f21..cb74b1d8a790 100644 --- a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractor.java +++ b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractor.java @@ -8,7 +8,7 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.instrumentation.api.config.Config; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.Map; import org.checkerframework.checker.nullness.qual.Nullable; @@ -28,12 +28,12 @@ public final class PeerServiceAttributesOnStartExtractor Config.get().getMap("otel.instrumentation.common.peer-service-mapping"); private final Map peerServiceMapping; - private final NetAttributesOnStartExtractor netAttributesExtractor; + private final NetAttributesServerExtractor netAttributesExtractor; // visible for tests PeerServiceAttributesOnStartExtractor( Map peerServiceMapping, - NetAttributesOnStartExtractor netAttributesExtractor) { + NetAttributesServerExtractor netAttributesExtractor) { this.peerServiceMapping = peerServiceMapping; this.netAttributesExtractor = netAttributesExtractor; } @@ -43,7 +43,7 @@ public final class PeerServiceAttributesOnStartExtractor * netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute. */ public static PeerServiceAttributesOnStartExtractor create( - NetAttributesOnStartExtractor netAttributesExtractor) { + NetAttributesServerExtractor netAttributesExtractor) { return new PeerServiceAttributesOnStartExtractor<>( JAVAAGENT_PEER_SERVICE_MAPPING, netAttributesExtractor); } diff --git a/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractorTest.java b/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractorTest.java index 4c66b637478c..cfa507e25a39 100644 --- a/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractorTest.java +++ b/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractorTest.java @@ -14,7 +14,7 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnEndExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.HashMap; import java.util.Map; @@ -25,7 +25,7 @@ @ExtendWith(MockitoExtension.class) class PeerServiceAttributesOnEndExtractorTest { - @Mock NetAttributesOnEndExtractor netAttributesExtractor; + @Mock NetAttributesClientExtractor netAttributesExtractor; @Test void shouldNotSetAnyValueIfNetExtractorReturnsNulls() { diff --git a/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractorTest.java b/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractorTest.java index d22d7b783daf..1a4eb4a75c40 100644 --- a/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractorTest.java +++ b/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractorTest.java @@ -14,7 +14,7 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.HashMap; import java.util.Map; @@ -25,7 +25,7 @@ @ExtendWith(MockitoExtension.class) class PeerServiceAttributesOnStartExtractorTest { - @Mock NetAttributesOnStartExtractor netAttributesExtractor; + @Mock NetAttributesServerExtractor netAttributesExtractor; @Test void shouldNotSetAnyValueIfNetExtractorReturnsNulls() { From 16217dc97421bdbfceb464ed5d9d75f3302918a0 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Tue, 5 Oct 2021 11:51:50 -0700 Subject: [PATCH 08/26] Fix merge conflict in main --- .../tooling/instrumentation/InstrumentationModuleInstaller.java | 1 + 1 file changed, 1 insertion(+) diff --git a/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/instrumentation/InstrumentationModuleInstaller.java b/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/instrumentation/InstrumentationModuleInstaller.java index 54fa7b46a4d7..3d55af986aa7 100644 --- a/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/instrumentation/InstrumentationModuleInstaller.java +++ b/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/instrumentation/InstrumentationModuleInstaller.java @@ -19,6 +19,7 @@ import io.opentelemetry.javaagent.tooling.field.VirtualFieldImplementationInstaller; import io.opentelemetry.javaagent.tooling.field.VirtualFieldImplementationInstallerFactory; import io.opentelemetry.javaagent.tooling.muzzle.HelperResourceBuilderImpl; +import io.opentelemetry.javaagent.tooling.muzzle.InstrumentationModuleMuzzle; import io.opentelemetry.javaagent.tooling.muzzle.Mismatch; import io.opentelemetry.javaagent.tooling.muzzle.ReferenceMatcher; import java.lang.instrument.Instrumentation; From 44bcbe1109447f3242c962a1ffc0cbb79fc1a5f6 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Tue, 5 Oct 2021 13:35:35 -0700 Subject: [PATCH 09/26] more --- .../benchmark/InstrumenterBenchmark.java | 4 +-- ...tAddressNetAttributesClientExtractor.java} | 2 +- ...tAddressNetAttributesServerExtractor.java} | 2 +- .../net/NetAttributesClientExtractor.java | 2 +- .../net/NetAttributesServerExtractor.java | 2 +- ...ressNetAttributesClientExtractorTest.java} | 6 ++-- ...ressNetAttributesServerExtractorTest.java} | 6 ++-- .../apachedubbo/v2_7/OpenTelemetryFilter.java | 9 ++--- .../apachedubbo/v2_7/DubboTracingBuilder.java | 13 +++++--- .../DubboNetClientAttributesExtractor.java | 26 +++++++++++++++ ...=> DubboNetServerAttributesExtractor.java} | 6 ++-- ...HttpAsyncClientNetAttributesExtractor.java | 13 ++++---- .../ApacheHttpAsyncClientSingletons.java | 4 +-- ...pacheHttpClientNetAttributesExtractor.java | 12 +++---- .../v2_0/ApacheHttpClientSingletons.java | 4 +-- ...pacheHttpClientNetAttributesExtractor.java | 13 ++++---- .../v4_0/ApacheHttpClientSingletons.java | 4 +-- ...pacheHttpClientNetAttributesExtractor.java | 12 +++---- ...pacheHttpClientNetAttributesExtractor.java | 12 +++---- .../v5_0/ApacheHttpClientSingletons.java | 4 +-- .../armeria/v1_3/ArmeriaSingletons.java | 13 +++++--- .../armeria/v1_3/ArmeriaTracingBuilder.java | 13 +++----- ... ArmeriaNetClientAttributesExtractor.java} | 6 ++-- .../ArmeriaNetServerAttributesExtractor.java | 33 +++++++++++++++++++ ...AsyncHttpClientNetAttributesExtractor.java | 12 +++---- .../v1_9/AsyncHttpClientSingletons.java | 4 +-- ...AsyncHttpClientNetAttributesExtractor.java | 4 +-- .../v2_0/AsyncHttpClientSingletons.java | 4 +-- .../v3_0/CassandraNetAttributesExtractor.java | 4 +-- .../v4_0/CassandraNetAttributesExtractor.java | 4 +-- .../ElasticsearchRestInstrumenterFactory.java | 4 +-- ...earch6TransportNetAttributesExtractor.java | 4 +-- ...oogleHttpClientNetAttributesExtractor.java | 12 +++---- .../GoogleHttpClientSingletons.java | 4 +-- .../grpc/v1_6/GrpcSingletons.java | 8 ++--- .../grpc/v1_6/GrpcTracingBuilder.java | 16 +++++---- .../GrpcNetClientAttributesExtractor.java | 32 ++++++++++++++++++ ... => GrpcNetServerAttributesExtractor.java} | 6 ++-- .../HttpUrlConnectionSingletons.java | 4 +-- .../HttpUrlNetAttributesExtractor.java | 12 +++---- .../httpclient/JdkHttpClientSingletons.java | 4 +-- .../JaxRsClientNetAttributesExtractor.java | 12 +++---- .../v1_1/JaxRsClientSingletons.java | 4 +-- .../v2_0/JaxRsClientSingletons.java | 4 +-- .../v2_0/ResteasyClientSingletons.java | 4 +-- .../instrumentation/jdbc/JdbcSingletons.java | 4 +-- .../jedis/v1_4/JedisSingletons.java | 4 +-- .../v3_0/JedisNetAttributesExtractor.java | 8 ++--- .../jedis/v3_0/JedisSingletons.java | 4 +-- .../v9_2/JettyHttpClientSingletons.java | 6 ++-- .../lettuce/v4_0/LettuceSingletons.java | 4 +-- .../lettuce/v5_0/LettuceSingletons.java | 4 +-- .../LibertyDispatcherSingletons.java | 4 +-- .../okhttp/v2_2/OkHttp2Singletons.java | 4 +-- .../okhttp/v3_0/OkHttp3Singletons.java | 4 +-- .../PlayWsClientNetAttributesExtractor.java | 4 +-- .../playws/PlayWsClientSingletons.java | 4 +-- .../RedissonNetAttributesExtractor.java | 8 ++--- .../servlet/ServletInstrumenterBuilder.java | 4 +-- .../common/TomcatInstrumenterBuilder.java | 5 ++- .../UndertowNetAttributesExtractor.java | 4 +-- .../undertow/UndertowSingletons.java | 4 +-- ...PeerServiceAttributesClientExtractor.java} | 10 +++--- ...PeerServiceAttributesServerExtractor.java} | 10 +++--- ...ServiceAttributesClientExtractorTest.java} | 22 ++++++------- ...ServiceAttributesServerExtractorTest.java} | 22 ++++++------- 66 files changed, 312 insertions(+), 214 deletions(-) rename instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/{InetSocketAddressNetClientAttributesExtractor.java => InetSocketAddressNetAttributesClientExtractor.java} (97%) rename instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/{InetSocketAddressNetServerAttributesExtractor.java => InetSocketAddressNetAttributesServerExtractor.java} (96%) rename instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/{InetSocketAddressNetClientAttributesExtractorTest.java => InetSocketAddressNetAttributesClientExtractorTest.java} (93%) rename instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/{InetSocketAddressNetServerAttributesExtractorTest.java => InetSocketAddressNetAttributesServerExtractorTest.java} (93%) create mode 100644 instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetClientAttributesExtractor.java rename instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/{DubboNetAttributesExtractor.java => DubboNetServerAttributesExtractor.java} (80%) rename instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/{ArmeriaNetAttributesExtractor.java => ArmeriaNetClientAttributesExtractor.java} (85%) create mode 100644 instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetServerAttributesExtractor.java create mode 100644 instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetClientAttributesExtractor.java rename instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/{GrpcNetAttributesExtractor.java => GrpcNetServerAttributesExtractor.java} (84%) rename javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/{PeerServiceAttributesOnEndExtractor.java => PeerServiceAttributesClientExtractor.java} (88%) rename javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/{PeerServiceAttributesOnStartExtractor.java => PeerServiceAttributesServerExtractor.java} (88%) rename javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/{PeerServiceAttributesOnEndExtractorTest.java => PeerServiceAttributesClientExtractorTest.java} (83%) rename javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/{PeerServiceAttributesOnStartExtractorTest.java => PeerServiceAttributesServerExtractorTest.java} (82%) diff --git a/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java b/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java index 633157993bc5..fbfdb38c2938 100644 --- a/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java +++ b/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java @@ -11,7 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.CapturedHttpHeaders; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import java.util.Collections; @@ -120,7 +120,7 @@ protected List responseHeader(Void unused, Void unused2, String name) { } static class ConstantNetAttributesExtractor - extends InetSocketAddressNetServerAttributesExtractor { + extends InetSocketAddressNetAttributesServerExtractor { private static final InetSocketAddress ADDRESS = InetSocketAddress.createUnresolved("localhost", 8080); 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/InetSocketAddressNetAttributesClientExtractor.java similarity index 97% 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/InetSocketAddressNetAttributesClientExtractor.java index 3451e3b0dd2d..2f81dca4d9e9 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/InetSocketAddressNetAttributesClientExtractor.java @@ -16,7 +16,7 @@ * {@link InetSocketAddress} so this is a convenient alternative to {@link * NetAttributesClientExtractor}. There is no meaning to implement both in the same instrumentation. */ -public abstract class InetSocketAddressNetClientAttributesExtractor +public abstract class InetSocketAddressNetAttributesClientExtractor extends NetAttributesClientExtractor { /** diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractor.java similarity index 96% rename from instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesExtractor.java rename to instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractor.java index e1b959730654..a627c8aa7c16 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractor.java @@ -16,7 +16,7 @@ * {@link InetSocketAddress} so this is a convenient alternative to {@link * NetAttributesServerExtractor}. There is no meaning to implement both in the same instrumentation. */ -public abstract class InetSocketAddressNetServerAttributesExtractor +public abstract class InetSocketAddressNetAttributesServerExtractor extends NetAttributesServerExtractor { /** diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractor.java index cf0a5316d598..ee5a76e1fae9 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractor.java @@ -14,7 +14,7 @@ * 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 InetSocketAddressNetAttributesClientExtractor}. */ public abstract class NetAttributesClientExtractor extends AttributesExtractor { diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractor.java index 37fb893f6bad..e745911c92e1 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractor.java @@ -14,7 +14,7 @@ * 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 InetSocketAddressNetServerAttributesExtractor}. + * it is more convenient to use {@link InetSocketAddressNetAttributesServerExtractor}. */ public abstract class NetAttributesServerExtractor extends AttributesExtractor { 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/InetSocketAddressNetAttributesClientExtractorTest.java similarity index 93% 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/InetSocketAddressNetAttributesClientExtractorTest.java index 73b0ec121748..f5a5e2644c87 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/InetSocketAddressNetAttributesClientExtractorTest.java @@ -17,11 +17,11 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class InetSocketAddressNetClientAttributesExtractorTest { +class InetSocketAddressNetAttributesClientExtractorTest { - private final InetSocketAddressNetClientAttributesExtractor + private final InetSocketAddressNetAttributesClientExtractor extractor = - new InetSocketAddressNetClientAttributesExtractor< + new InetSocketAddressNetAttributesClientExtractor< InetSocketAddress, InetSocketAddress>() { @Override public InetSocketAddress getAddress( diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractorTest.java similarity index 93% rename from instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesExtractorTest.java rename to instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractorTest.java index 3a775e35ccb0..e9b02ae34851 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractorTest.java @@ -17,11 +17,11 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class InetSocketAddressNetServerAttributesExtractorTest { +class InetSocketAddressNetAttributesServerExtractorTest { - private final InetSocketAddressNetServerAttributesExtractor + private final InetSocketAddressNetAttributesServerExtractor extractor = - new InetSocketAddressNetServerAttributesExtractor< + new InetSocketAddressNetAttributesServerExtractor< InetSocketAddress, InetSocketAddress>() { @Override public InetSocketAddress getAddress(InetSocketAddress request) { diff --git a/instrumentation/apache-dubbo-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachedubbo/v2_7/OpenTelemetryFilter.java b/instrumentation/apache-dubbo-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachedubbo/v2_7/OpenTelemetryFilter.java index a2c1c44bd8c0..2b2befb10032 100644 --- a/instrumentation/apache-dubbo-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachedubbo/v2_7/OpenTelemetryFilter.java +++ b/instrumentation/apache-dubbo-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachedubbo/v2_7/OpenTelemetryFilter.java @@ -7,8 +7,8 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.apachedubbo.v2_7.DubboTracing; -import io.opentelemetry.instrumentation.apachedubbo.v2_7.internal.DubboNetAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.apachedubbo.v2_7.internal.DubboNetServerAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; import org.apache.dubbo.common.extension.Activate; import org.apache.dubbo.rpc.Filter; import org.apache.dubbo.rpc.Invocation; @@ -21,11 +21,12 @@ public class OpenTelemetryFilter implements Filter { private final Filter delegate; public OpenTelemetryFilter() { - DubboNetAttributesExtractor netAttributesExtractor = new DubboNetAttributesExtractor(); + DubboNetServerAttributesExtractor netAttributesExtractor = + new DubboNetServerAttributesExtractor(); delegate = DubboTracing.newBuilder(GlobalOpenTelemetry.get()) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) .build() .newFilter(); } diff --git a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java index 1ca734a805fe..3d59bd783b15 100644 --- a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java +++ b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java @@ -6,7 +6,8 @@ package io.opentelemetry.instrumentation.apachedubbo.v2_7; import io.opentelemetry.api.OpenTelemetry; -import io.opentelemetry.instrumentation.apachedubbo.v2_7.internal.DubboNetAttributesExtractor; +import io.opentelemetry.instrumentation.apachedubbo.v2_7.internal.DubboNetClientAttributesExtractor; +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; @@ -42,7 +43,6 @@ public DubboTracingBuilder addAttributesExtractor( /** Returns a new {@link DubboTracing} with the settings of this {@link DubboTracingBuilder}. */ public DubboTracing build() { DubboRpcAttributesExtractor rpcAttributesExtractor = new DubboRpcAttributesExtractor(); - DubboNetAttributesExtractor netAttributesExtractor = new DubboNetAttributesExtractor(); SpanNameExtractor spanNameExtractor = RpcSpanNameExtractor.create(rpcAttributesExtractor); @@ -50,11 +50,14 @@ public DubboTracing build() { Instrumenter.newBuilder( openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor) .addAttributesExtractor(rpcAttributesExtractor) - .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractors(attributesExtractors); return new DubboTracing( - builder.newServerInstrumenter(new DubboHeadersGetter()), - builder.newClientInstrumenter(new DubboHeadersSetter())); + builder + .addAttributesExtractor(new DubboNetServerAttributesExtractor()) + .newServerInstrumenter(new DubboHeadersGetter()), + builder + .addAttributesExtractor(new DubboNetClientAttributesExtractor()) + .newClientInstrumenter(new DubboHeadersSetter())); } } diff --git a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetClientAttributesExtractor.java b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetClientAttributesExtractor.java new file mode 100644 index 000000000000..6b16ca3c45ad --- /dev/null +++ b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetClientAttributesExtractor.java @@ -0,0 +1,26 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.apachedubbo.v2_7.internal; + +import io.opentelemetry.instrumentation.apachedubbo.v2_7.DubboRequest; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesClientExtractor; +import java.net.InetSocketAddress; +import org.apache.dubbo.rpc.Result; +import org.checkerframework.checker.nullness.qual.Nullable; + +public final class DubboNetClientAttributesExtractor + extends InetSocketAddressNetAttributesClientExtractor { + + @Override + public @Nullable InetSocketAddress getAddress(DubboRequest request, @Nullable Result response) { + return request.context().getRemoteAddress(); + } + + @Override + public @Nullable String transport(DubboRequest request, @Nullable Result response) { + return null; + } +} diff --git a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetAttributesExtractor.java b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetServerAttributesExtractor.java similarity index 80% rename from instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetAttributesExtractor.java rename to instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetServerAttributesExtractor.java index 0ff9e6d1feb8..437bd05f4835 100644 --- a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetAttributesExtractor.java +++ b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetServerAttributesExtractor.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.InetSocketAddressNetServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesServerExtractor; import java.net.InetSocketAddress; import org.apache.dubbo.rpc.Result; import org.checkerframework.checker.nullness.qual.Nullable; -public final class DubboNetAttributesExtractor - extends InetSocketAddressNetServerAttributesExtractor { +public final class DubboNetServerAttributesExtractor + extends InetSocketAddressNetAttributesServerExtractor { @Override public @Nullable InetSocketAddress getAddress(DubboRequest request) { 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/ApacheHttpAsyncClientNetAttributesExtractor.java index 8f234da50481..35d7b753ef37 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/ApacheHttpAsyncClientNetAttributesExtractor.java @@ -5,31 +5,32 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpasyncclient; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.http.HttpResponse; import org.checkerframework.checker.nullness.qual.Nullable; final class ApacheHttpAsyncClientNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetAttributesClientExtractor { @Override - public String transport(ApacheHttpClientRequest request) { + public String transport(ApacheHttpClientRequest request, @Nullable HttpResponse response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public @Nullable String peerName(ApacheHttpClientRequest request) { + public @Nullable String peerName( + ApacheHttpClientRequest request, @Nullable HttpResponse response) { return request.getPeerName(); } @Override - public Integer peerPort(ApacheHttpClientRequest request) { + public Integer peerPort(ApacheHttpClientRequest request, @Nullable HttpResponse response) { return request.getPeerPort(); } @Override - public @Nullable String peerIp(ApacheHttpClientRequest request) { + public @Nullable String peerIp(ApacheHttpClientRequest request, @Nullable HttpResponse response) { return null; } } 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 37fc0bf7f28a..345f81196b67 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 @@ -13,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; import org.apache.http.HttpResponse; public final class ApacheHttpAsyncClientSingletons { @@ -38,7 +38,7 @@ public final class ApacheHttpAsyncClientSingletons { .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } 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/ApacheHttpClientNetAttributesExtractor.java index 49faf8d124e3..2cdf1853d2e9 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/ApacheHttpClientNetAttributesExtractor.java @@ -5,34 +5,34 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.commons.httpclient.HostConfiguration; import org.apache.commons.httpclient.HttpMethod; import org.checkerframework.checker.nullness.qual.Nullable; final class ApacheHttpClientNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetAttributesClientExtractor { @Override - public String transport(HttpMethod request) { + public String transport(HttpMethod request, @Nullable HttpMethod response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public @Nullable String peerName(HttpMethod request) { + public @Nullable String peerName(HttpMethod request, @Nullable HttpMethod response) { HostConfiguration hostConfiguration = request.getHostConfiguration(); return hostConfiguration != null ? hostConfiguration.getHost() : null; } @Override - public @Nullable Integer peerPort(HttpMethod request) { + public @Nullable Integer peerPort(HttpMethod request, @Nullable HttpMethod response) { HostConfiguration hostConfiguration = request.getHostConfiguration(); return hostConfiguration != null ? hostConfiguration.getPort() : null; } @Override - public @Nullable String peerIp(HttpMethod request) { + public @Nullable String peerIp(HttpMethod request, @Nullable HttpMethod response) { return null; } } 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 3cb235004a0a..4e53a2d95078 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 @@ -13,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; import org.apache.commons.httpclient.HttpMethod; public final class ApacheHttpClientSingletons { @@ -38,7 +38,7 @@ public final class ApacheHttpClientSingletons { .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } 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/ApacheHttpClientNetAttributesExtractor.java index 32de57a6b318..8d5cc19698be 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/ApacheHttpClientNetAttributesExtractor.java @@ -5,31 +5,32 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v4_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.http.HttpResponse; import org.checkerframework.checker.nullness.qual.Nullable; final class ApacheHttpClientNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetAttributesClientExtractor { @Override - public String transport(ApacheHttpClientRequest request) { + public String transport(ApacheHttpClientRequest request, @Nullable HttpResponse response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public @Nullable String peerName(ApacheHttpClientRequest request) { + public @Nullable String peerName( + ApacheHttpClientRequest request, @Nullable HttpResponse response) { return request.getPeerName(); } @Override - public Integer peerPort(ApacheHttpClientRequest request) { + public Integer peerPort(ApacheHttpClientRequest request, @Nullable HttpResponse response) { return request.getPeerPort(); } @Override - public @Nullable String peerIp(ApacheHttpClientRequest request) { + public @Nullable String peerIp(ApacheHttpClientRequest request, @Nullable HttpResponse response) { return null; } } 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 7f026ddc2de5..fcb764bf31a6 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 @@ -13,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; import org.apache.http.HttpResponse; public final class ApacheHttpClientSingletons { @@ -38,7 +38,7 @@ public final class ApacheHttpClientSingletons { .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } 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/ApacheHttpClientNetAttributesExtractor.java index 86085eadb1f9..3a3e17a63630 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/ApacheHttpClientNetAttributesExtractor.java @@ -5,34 +5,34 @@ package io.opentelemetry.instrumentation.apachehttpclient.v4_3; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.http.HttpResponse; import org.checkerframework.checker.nullness.qual.Nullable; final class ApacheHttpClientNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetAttributesClientExtractor { @Override - public String transport(ApacheHttpClientRequest request) { + public String transport(ApacheHttpClientRequest request, @Nullable HttpResponse response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override @Nullable - public String peerName(ApacheHttpClientRequest request) { + public String peerName(ApacheHttpClientRequest request, @Nullable HttpResponse response) { return request.getPeerName(); } @Override @Nullable - public Integer peerPort(ApacheHttpClientRequest request) { + public Integer peerPort(ApacheHttpClientRequest request, @Nullable HttpResponse response) { return request.getPeerPort(); } @Override @Nullable - public String peerIp(ApacheHttpClientRequest request) { + public String peerIp(ApacheHttpClientRequest request, @Nullable HttpResponse response) { return null; } } 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/ApacheHttpClientNetAttributesExtractor.java index ba3c1420bb1d..6171711e8172 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/ApacheHttpClientNetAttributesExtractor.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v5_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.HttpResponse; @@ -14,23 +14,23 @@ import org.slf4j.LoggerFactory; final class ApacheHttpClientNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetAttributesClientExtractor { private static final Logger logger = LoggerFactory.getLogger(ApacheHttpClientNetAttributesExtractor.class); @Override - public String transport(ClassicHttpRequest request) { + public String transport(ClassicHttpRequest request, @Nullable HttpResponse response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public @Nullable String peerName(ClassicHttpRequest request) { + public @Nullable String peerName(ClassicHttpRequest request, @Nullable HttpResponse response) { return request.getAuthority().getHostName(); } @Override - public Integer peerPort(ClassicHttpRequest request) { + public Integer peerPort(ClassicHttpRequest request, @Nullable HttpResponse response) { int port = request.getAuthority().getPort(); if (port != -1) { return port; @@ -51,7 +51,7 @@ public Integer peerPort(ClassicHttpRequest request) { } @Override - public @Nullable String peerIp(ClassicHttpRequest request) { + public @Nullable String peerIp(ClassicHttpRequest request, @Nullable HttpResponse response) { return null; } } 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 8be1abb399c9..2c0576569e93 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 @@ -13,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.HttpResponse; @@ -39,7 +39,7 @@ public final class ApacheHttpClientSingletons { .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } diff --git a/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java b/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java index 6600d9b33e88..fb57cdc2203b 100644 --- a/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java +++ b/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java @@ -11,8 +11,8 @@ import com.linecorp.armeria.server.HttpService; import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.armeria.v1_3.ArmeriaTracing; -import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaNetAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnEndExtractor; +import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaNetClientAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesClientExtractor; import java.util.function.Function; // Holds singleton references to decorators to match against during suppression. @@ -23,12 +23,15 @@ public final class ArmeriaSingletons { public static final Function SERVER_DECORATOR; static { - PeerServiceAttributesOnEndExtractor peerServiceAttributesExtractor = - PeerServiceAttributesOnEndExtractor.create(new ArmeriaNetAttributesExtractor()); + // TODO (trask) split ArmeriaNetAttributesExtractor into client/server + // (and move into ArmeriaTracingBuilder?) + PeerServiceAttributesClientExtractor + peerServiceAttributesClientExtractor = + PeerServiceAttributesClientExtractor.create(new ArmeriaNetClientAttributesExtractor()); ArmeriaTracing tracing = ArmeriaTracing.newBuilder(GlobalOpenTelemetry.get()) - .addAttributeExtractor(peerServiceAttributesExtractor) + .addAttributeExtractor(peerServiceAttributesClientExtractor) .build(); CLIENT_DECORATOR = tracing.newClientDecorator(); 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 13e884b1724c..d45cbc29b787 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 @@ -18,7 +18,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.armeria.v1_3.internal.ArmeriaNetAttributesExtractor; +import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaNetServerAttributesExtractor; import java.util.ArrayList; import java.util.List; import java.util.function.Function; @@ -67,8 +68,6 @@ public ArmeriaTracing build() { ArmeriaHttpServerAttributesExtractor serverAttributesExtractor = new ArmeriaHttpServerAttributesExtractor(); - ArmeriaNetAttributesExtractor netAttributesExtractor = new ArmeriaNetAttributesExtractor(); - InstrumenterBuilder clientInstrumenterBuilder = Instrumenter.newBuilder( openTelemetry, @@ -81,22 +80,20 @@ public ArmeriaTracing build() { HttpSpanNameExtractor.create(serverAttributesExtractor)); Stream.of(clientInstrumenterBuilder, serverInstrumenterBuilder) - .forEach( - instrumenter -> - instrumenter - .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractors(additionalExtractors)); + .forEach(instrumenter -> instrumenter.addAttributesExtractors(additionalExtractors)); clientInstrumenterBuilder .setSpanStatusExtractor( statusExtractorTransformer.apply( HttpSpanStatusExtractor.create(clientAttributesExtractor))) + .addAttributesExtractor(new ArmeriaNetClientAttributesExtractor()) .addAttributesExtractor(clientAttributesExtractor) .addRequestMetrics(HttpClientMetrics.get()); serverInstrumenterBuilder .setSpanStatusExtractor( statusExtractorTransformer.apply( HttpSpanStatusExtractor.create(serverAttributesExtractor))) + .addAttributesExtractor(new ArmeriaNetServerAttributesExtractor()) .addAttributesExtractor(serverAttributesExtractor) .addRequestMetrics(HttpServerMetrics.get()); diff --git a/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetAttributesExtractor.java b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetClientAttributesExtractor.java similarity index 85% rename from instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetAttributesExtractor.java rename to instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetClientAttributesExtractor.java index 8faec062323c..5c8c7a392af9 100644 --- a/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetAttributesExtractor.java +++ b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetClientAttributesExtractor.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.InetSocketAddressNetAttributesClientExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import java.net.SocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; -public final class ArmeriaNetAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { +public final class ArmeriaNetClientAttributesExtractor + extends InetSocketAddressNetAttributesClientExtractor { @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/internal/ArmeriaNetServerAttributesExtractor.java b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetServerAttributesExtractor.java new file mode 100644 index 000000000000..93c68fdeb701 --- /dev/null +++ b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetServerAttributesExtractor.java @@ -0,0 +1,33 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.armeria.v1_3.internal; + +import com.linecorp.armeria.common.RequestContext; +import com.linecorp.armeria.common.logging.RequestLog; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesServerExtractor; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import org.checkerframework.checker.nullness.qual.Nullable; + +public final class ArmeriaNetServerAttributesExtractor + extends InetSocketAddressNetAttributesServerExtractor { + + @Override + public String transport(RequestContext ctx) { + return SemanticAttributes.NetTransportValues.IP_TCP; + } + + @Override + @Nullable + public InetSocketAddress getAddress(RequestContext ctx) { + SocketAddress address = ctx.remoteAddress(); + if (address instanceof InetSocketAddress) { + return (InetSocketAddress) address; + } + return null; + } +} 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/AsyncHttpClientNetAttributesExtractor.java index 35f3b6d4f8b5..914910f342b0 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/AsyncHttpClientNetAttributesExtractor.java @@ -7,31 +7,31 @@ import com.ning.http.client.Request; import com.ning.http.client.Response; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; final class AsyncHttpClientNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetAttributesClientExtractor { @Override - public String transport(Request request) { + public String transport(Request request, @Nullable Response response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public String peerName(Request request) { + public String peerName(Request request, @Nullable Response response) { return request.getUri().getHost(); } @Override - public Integer peerPort(Request request) { + public Integer peerPort(Request request, @Nullable Response response) { return request.getUri().getPort(); } @Override @Nullable - public String peerIp(Request request) { + public String peerIp(Request request, @Nullable Response response) { return null; } } 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 ba145fc6ac4f..a53be7b55f6e 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 @@ -15,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; public final class AsyncHttpClientSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.async-http-client-1.9"; @@ -39,7 +39,7 @@ public final class AsyncHttpClientSingletons { .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } 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/AsyncHttpClientNetAttributesExtractor.java index 2112422c20c5..c654b8e9ecf5 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/AsyncHttpClientNetAttributesExtractor.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.InetSocketAddressNetAttributesClientExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import org.asynchttpclient.Response; import org.checkerframework.checker.nullness.qual.Nullable; final class AsyncHttpClientNetAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { + extends InetSocketAddressNetAttributesClientExtractor { @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 c4cf016aa5da..d8a6e113e083 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 @@ -14,7 +14,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnEndExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesClientExtractor; import org.asynchttpclient.Response; public final class AsyncHttpClientSingletons { @@ -39,7 +39,7 @@ public final class AsyncHttpClientSingletons { .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnEndExtractor.create(netAttributesExtractor)) + PeerServiceAttributesClientExtractor.create(netAttributesExtractor)) .addAttributesExtractor(new AsyncHttpClientAdditionalAttributesExtractor()) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); 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/CassandraNetAttributesExtractor.java index d3b3d22a0ec9..8bde531e4387 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/CassandraNetAttributesExtractor.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.InetSocketAddressNetAttributesClientExtractor; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; final class CassandraNetAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { + extends InetSocketAddressNetAttributesClientExtractor { @Override @Nullable 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/CassandraNetAttributesExtractor.java index 89accdb0c179..d4a65e785dae 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/CassandraNetAttributesExtractor.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.InetSocketAddressNetAttributesClientExtractor; import java.net.InetSocketAddress; import java.net.SocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; final class CassandraNetAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { + extends InetSocketAddressNetAttributesClientExtractor { @Override @Nullable 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 dd1fd3c3cda5..b62e1aa7ea47 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 @@ -10,7 +10,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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnEndExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesClientExtractor; import org.elasticsearch.client.Response; public final class ElasticsearchRestInstrumenterFactory { @@ -26,7 +26,7 @@ public static Instrumenter create(String instrumentationName) GlobalOpenTelemetry.get(), instrumentationName, spanNameExtractor) .addAttributesExtractor(attributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesOnEndExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesClientExtractor.create(netAttributesExtractor)) .newInstrumenter(SpanKindExtractor.alwaysClient()); } 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/Elasticsearch6TransportNetAttributesExtractor.java index 393d2ff4e963..5e8601ee2820 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/Elasticsearch6TransportNetAttributesExtractor.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.InetSocketAddressNetAttributesClientExtractor; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportRequest; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; import org.elasticsearch.action.ActionResponse; public class Elasticsearch6TransportNetAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { + extends InetSocketAddressNetAttributesClientExtractor { @Override public @Nullable 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/GoogleHttpClientNetAttributesExtractor.java index fadb23ca8be1..8c0ac56bff7e 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/GoogleHttpClientNetAttributesExtractor.java @@ -7,25 +7,25 @@ import com.google.api.client.http.HttpRequest; import com.google.api.client.http.HttpResponse; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; final class GoogleHttpClientNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetAttributesClientExtractor { @Override - public String transport(HttpRequest request) { + public String transport(HttpRequest request, @Nullable HttpResponse response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public @Nullable String peerName(HttpRequest request) { + public @Nullable String peerName(HttpRequest request, @Nullable HttpResponse response) { return request.getUrl().getHost(); } @Override - public Integer peerPort(HttpRequest request) { + public Integer peerPort(HttpRequest request, @Nullable HttpResponse response) { int port = request.getUrl().getPort(); if (port != -1) { return port; @@ -34,7 +34,7 @@ public Integer peerPort(HttpRequest request) { } @Override - public @Nullable String peerIp(HttpRequest request) { + public @Nullable String peerIp(HttpRequest request, @Nullable HttpResponse response) { return null; } } 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 0d57ec920ce3..6e7667ab149d 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 @@ -15,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; public class GoogleHttpClientSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.google-http-client-1.19"; @@ -39,7 +39,7 @@ public class GoogleHttpClientSingletons { .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } diff --git a/instrumentation/grpc-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grpc/v1_6/GrpcSingletons.java b/instrumentation/grpc-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grpc/v1_6/GrpcSingletons.java index 4303ba6f9bff..f47edc4d893c 100644 --- a/instrumentation/grpc-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grpc/v1_6/GrpcSingletons.java +++ b/instrumentation/grpc-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grpc/v1_6/GrpcSingletons.java @@ -14,8 +14,8 @@ import io.opentelemetry.instrumentation.grpc.v1_6.GrpcRequest; import io.opentelemetry.instrumentation.grpc.v1_6.GrpcTracing; import io.opentelemetry.instrumentation.grpc.v1_6.internal.ContextStorageBridge; -import io.opentelemetry.instrumentation.grpc.v1_6.internal.GrpcNetAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.grpc.v1_6.internal.GrpcNetServerAttributesExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; // Holds singleton references. public final class GrpcSingletons { @@ -29,8 +29,8 @@ public final class GrpcSingletons { static { boolean experimentalSpanAttributes = Config.get().getBoolean("otel.instrumentation.grpc.experimental-span-attributes", false); - PeerServiceAttributesOnStartExtractor peerServiceAttributesExtractor = - PeerServiceAttributesOnStartExtractor.create(new GrpcNetAttributesExtractor()); + PeerServiceAttributesServerExtractor peerServiceAttributesExtractor = + PeerServiceAttributesServerExtractor.create(new GrpcNetServerAttributesExtractor()); GrpcTracing tracing = GrpcTracing.newBuilder(GlobalOpenTelemetry.get()) 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 e0a696396fba..08818edb1f63 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 @@ -11,7 +11,8 @@ import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; -import io.opentelemetry.instrumentation.grpc.v1_6.internal.GrpcNetAttributesExtractor; +import io.opentelemetry.instrumentation.grpc.v1_6.internal.GrpcNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.grpc.v1_6.internal.GrpcNetServerAttributesExtractor; import java.util.ArrayList; import java.util.List; @@ -58,16 +59,17 @@ public GrpcTracing build() { Instrumenter.newBuilder(openTelemetry, INSTRUMENTATION_NAME, new GrpcSpanNameExtractor()); instrumenterBuilder .setSpanStatusExtractor(new GrpcSpanStatusExtractor()) - .addAttributesExtractors( - new GrpcNetAttributesExtractor(), - new GrpcRpcAttributesExtractor(), - new GrpcAttributesExtractor()) + .addAttributesExtractors(new GrpcRpcAttributesExtractor(), new GrpcAttributesExtractor()) .addAttributesExtractors(additionalExtractors); return new GrpcTracing( - instrumenterBuilder.newServerInstrumenter(GrpcExtractAdapter.GETTER), + instrumenterBuilder + .addAttributesExtractor(new GrpcNetServerAttributesExtractor()) + .newServerInstrumenter(GrpcExtractAdapter.GETTER), // gRPC client interceptors require two phases, one to set up request and one to execute. // So we go ahead and inject manually in this instrumentation. - instrumenterBuilder.newInstrumenter(SpanKindExtractor.alwaysClient()), + instrumenterBuilder + .addAttributesExtractor(new GrpcNetClientAttributesExtractor()) + .newInstrumenter(SpanKindExtractor.alwaysClient()), openTelemetry.getPropagators(), captureExperimentalSpanAttributes); } 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/GrpcNetClientAttributesExtractor.java new file mode 100644 index 000000000000..e7d7034b4bc5 --- /dev/null +++ b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetClientAttributesExtractor.java @@ -0,0 +1,32 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.grpc.v1_6.internal; + +import io.grpc.Status; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesClientExtractor; +import io.opentelemetry.instrumentation.grpc.v1_6.GrpcRequest; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import org.checkerframework.checker.nullness.qual.Nullable; + +public final class GrpcNetClientAttributesExtractor + extends InetSocketAddressNetAttributesClientExtractor { + @Override + @Nullable + public InetSocketAddress getAddress(GrpcRequest request, @Nullable Status response) { + SocketAddress address = request.getRemoteAddress(); + if (address instanceof InetSocketAddress) { + return (InetSocketAddress) address; + } + return null; + } + + @Override + public String transport(GrpcRequest request, @Nullable Status response) { + return SemanticAttributes.NetTransportValues.IP_TCP; + } +} diff --git a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetAttributesExtractor.java b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetServerAttributesExtractor.java similarity index 84% rename from instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetAttributesExtractor.java rename to instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetServerAttributesExtractor.java index 73ba5fa3bf43..777693e0201c 100644 --- a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetAttributesExtractor.java +++ b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetServerAttributesExtractor.java @@ -6,15 +6,15 @@ package io.opentelemetry.instrumentation.grpc.v1_6.internal; import io.grpc.Status; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesServerExtractor; import io.opentelemetry.instrumentation.grpc.v1_6.GrpcRequest; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import java.net.SocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; -public final class GrpcNetAttributesExtractor - extends InetSocketAddressNetServerAttributesExtractor { +public final class GrpcNetServerAttributesExtractor + extends InetSocketAddressNetAttributesServerExtractor { @Override @Nullable public InetSocketAddress getAddress(GrpcRequest request) { 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 9870225ba308..9393cb8a06a1 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,7 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; import java.net.HttpURLConnection; public class HttpUrlConnectionSingletons { @@ -32,7 +32,7 @@ public class HttpUrlConnectionSingletons { .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) .newClientInstrumenter(SETTER); } 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/HttpUrlNetAttributesExtractor.java index 71b21380c064..b557414b8e91 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/HttpUrlNetAttributesExtractor.java @@ -5,30 +5,30 @@ package io.opentelemetry.javaagent.instrumentation.httpurlconnection; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.HttpURLConnection; import org.checkerframework.checker.nullness.qual.Nullable; class HttpUrlNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetAttributesClientExtractor { @Override - public @Nullable String transport(HttpURLConnection connection) { + public @Nullable String transport(HttpURLConnection connection, @Nullable Integer status) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public String peerName(HttpURLConnection connection) { + public String peerName(HttpURLConnection connection, @Nullable Integer status) { return connection.getURL().getHost(); } @Override - public Integer peerPort(HttpURLConnection connection) { + public Integer peerPort(HttpURLConnection connection, @Nullable Integer status) { return connection.getURL().getPort(); } @Override - public @Nullable String peerIp(HttpURLConnection connection) { + public @Nullable String peerIp(HttpURLConnection connection, @Nullable Integer status) { return null; } } 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 6d2d685d0046..0a8015ffd1f7 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 @@ -12,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; import java.net.http.HttpRequest; import java.net.http.HttpResponse; @@ -37,7 +37,7 @@ public class JdkHttpClientSingletons { .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(SETTER); } 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/JaxRsClientNetAttributesExtractor.java index 6d323194a558..9c22719e736d 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/JaxRsClientNetAttributesExtractor.java @@ -7,25 +7,25 @@ import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; final class JaxRsClientNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetAttributesClientExtractor { @Override - public String transport(ClientRequest request) { + public String transport(ClientRequest request, @Nullable ClientResponse response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public @Nullable String peerName(ClientRequest request) { + public @Nullable String peerName(ClientRequest request, @Nullable ClientResponse response) { return request.getURI().getHost(); } @Override - public Integer peerPort(ClientRequest request) { + public Integer peerPort(ClientRequest request, @Nullable ClientResponse response) { int port = request.getURI().getPort(); if (port != -1) { return port; @@ -34,7 +34,7 @@ public Integer peerPort(ClientRequest request) { } @Override - public @Nullable String peerIp(ClientRequest request) { + public @Nullable String peerIp(ClientRequest request, @Nullable ClientResponse response) { return null; } } 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 ab81b6d67925..253fe49813a6 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 @@ -15,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; public class JaxRsClientSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jaxrs-client-1.1"; @@ -39,7 +39,7 @@ public class JaxRsClientSingletons { .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new InjectAdapter()); } 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 4a4481f8b6aa..31e058252e51 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 @@ -14,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; import javax.ws.rs.ProcessingException; import javax.ws.rs.client.ClientRequestContext; import javax.ws.rs.client.ClientResponseContext; @@ -48,7 +48,7 @@ public class JaxRsClientSingletons { .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new InjectAdapter()); } 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 3df69b2c61ec..bc1ef46c9005 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 @@ -14,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; import javax.ws.rs.ProcessingException; import javax.ws.rs.core.Response; import org.jboss.resteasy.client.jaxrs.internal.ClientInvocation; @@ -49,7 +49,7 @@ public class ResteasyClientSingletons { .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new ResteasyInjectAdapter()); } 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 f79ef692d298..171c78eee56b 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 @@ -14,7 +14,7 @@ import io.opentelemetry.instrumentation.jdbc.internal.DbRequest; import io.opentelemetry.instrumentation.jdbc.internal.JdbcAttributesExtractor; import io.opentelemetry.instrumentation.jdbc.internal.JdbcNetAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; public final class JdbcSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jdbc"; @@ -32,7 +32,7 @@ public final class JdbcSingletons { .addAttributesExtractor(dbAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) .newInstrumenter(SpanKindExtractor.alwaysClient()); } 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 9d71c20bf9f5..68dc58d3efb6 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 @@ -11,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; public final class JedisSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jedis-1.4"; @@ -30,7 +30,7 @@ public final class JedisSingletons { .addAttributesExtractor(attributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) .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/JedisNetAttributesExtractor.java index 5301c6c8c680..ca0c6acf95bc 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/JedisNetAttributesExtractor.java @@ -5,17 +5,17 @@ package io.opentelemetry.javaagent.instrumentation.jedis.v3_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesClientExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import java.net.Socket; import org.checkerframework.checker.nullness.qual.Nullable; final class JedisNetAttributesExtractor - extends InetSocketAddressNetServerAttributesExtractor { + extends InetSocketAddressNetAttributesClientExtractor { @Override - public @Nullable InetSocketAddress getAddress(JedisRequest jedisRequest) { + public @Nullable InetSocketAddress getAddress(JedisRequest jedisRequest, @Nullable Void unused) { Socket socket = jedisRequest.getConnection().getSocket(); if (socket != null && socket.getRemoteSocketAddress() instanceof InetSocketAddress) { return (InetSocketAddress) socket.getRemoteSocketAddress(); @@ -24,7 +24,7 @@ final class JedisNetAttributesExtractor } @Override - public String transport(JedisRequest jedisRequest) { + public String transport(JedisRequest jedisRequest, @Nullable Void unused) { return SemanticAttributes.NetTransportValues.IP_TCP; } } 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 059e00b1e02f..faa7fe1f9779 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 @@ -11,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; public final class JedisSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jedis-3.0"; @@ -30,7 +30,7 @@ public final class JedisSingletons { .addAttributesExtractor(attributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) .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 cac8e7301926..7f0f17ae87a4 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.jetty.httpclient.v9_2.internal.JettyClientInstrumenterBuilder; import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal.JettyHttpClientNetAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.api.Response; @@ -23,8 +23,8 @@ private JettyHttpClientSingletons() {} JettyClientInstrumenterBuilder builder = new JettyClientInstrumenterBuilder(GlobalOpenTelemetry.get()); - PeerServiceAttributesOnStartExtractor peerServiceAttributesExtractor = - PeerServiceAttributesOnStartExtractor.create(new JettyHttpClientNetAttributesExtractor()); + PeerServiceAttributesServerExtractor peerServiceAttributesExtractor = + PeerServiceAttributesServerExtractor.create(new JettyHttpClientNetAttributesExtractor()); INSTRUMENTER = builder.addAttributeExtractor(peerServiceAttributesExtractor).build(); } 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 d30f12bfdb20..b6dd017144ca 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 @@ -15,7 +15,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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; public final class LettuceSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.lettuce-4.0"; @@ -45,7 +45,7 @@ public final class LettuceSingletons { GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, redisUri -> "CONNECT") .addAttributesExtractor(connectNetAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(connectNetAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(connectNetAttributesExtractor)) .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/LettuceSingletons.java b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceSingletons.java index eadccd9117e8..3bd998117db2 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 @@ -15,7 +15,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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; public final class LettuceSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.lettuce-5.0"; @@ -45,7 +45,7 @@ public final class LettuceSingletons { GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, redisUri -> "CONNECT") .addAttributesExtractor(connectNetAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(connectNetAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(connectNetAttributesExtractor)) .addAttributesExtractor(new LettuceConnectAttributesExtractor()) .newInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java index d42c1c4f33ba..9316fa80b0d0 100644 --- a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java +++ b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java @@ -17,7 +17,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; public final class LibertyDispatcherSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.liberty-dispatcher"; @@ -41,7 +41,7 @@ public final class LibertyDispatcherSingletons { .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) .addContextCustomizer( (context, request, attributes) -> ServerSpanNaming.init(context, CONTAINER)) .addRequestMetrics(HttpServerMetrics.get()) 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 f4add5d8c1e3..e523a54e4df2 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 @@ -20,7 +20,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; public final class OkHttp2Singletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.okhttp-2.2"; @@ -47,7 +47,7 @@ public final class OkHttp2Singletons { .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) .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 7018d37f2c4a..9fd7c8c4d57f 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.okhttp.v3_0.OkHttpTracing; import io.opentelemetry.instrumentation.okhttp.v3_0.internal.OkHttpNetAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; 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.newBuilder(GlobalOpenTelemetry.get()) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(new OkHttpNetAttributesExtractor())) + PeerServiceAttributesServerExtractor.create(new OkHttpNetAttributesExtractor())) .build() .newInterceptor(); 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/PlayWsClientNetAttributesExtractor.java index 832da2e0897d..d6fd701d480e 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/PlayWsClientNetAttributesExtractor.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.playws; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesClientExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; @@ -13,7 +13,7 @@ import play.shaded.ahc.org.asynchttpclient.Response; final class PlayWsClientNetAttributesExtractor - extends InetSocketAddressNetClientAttributesExtractor { + extends InetSocketAddressNetAttributesClientExtractor { @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 c869efe97b1f..feb09c109d2a 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 @@ -13,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnEndExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesClientExtractor; import play.shaded.ahc.org.asynchttpclient.Request; import play.shaded.ahc.org.asynchttpclient.Response; @@ -39,7 +39,7 @@ public class PlayWsClientSingletons { .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnEndExtractor.create(netAttributesExtractor)) + PeerServiceAttributesClientExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } 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/RedissonNetAttributesExtractor.java index a33b35bc3a5f..925c29c1240d 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/RedissonNetAttributesExtractor.java @@ -5,21 +5,21 @@ package io.opentelemetry.javaagent.instrumentation.redisson; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesClientExtractor; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; final class RedissonNetAttributesExtractor - extends InetSocketAddressNetServerAttributesExtractor { + extends InetSocketAddressNetAttributesClientExtractor { @Override - public InetSocketAddress getAddress(RedissonRequest request) { + public InetSocketAddress getAddress(RedissonRequest request, @Nullable Void unused) { return request.getAddress(); } @Nullable @Override - public String transport(RedissonRequest request) { + public String transport(RedissonRequest request, @Nullable Void unused) { return null; } } diff --git a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java index c4e6392b5dc7..85f8863b4779 100644 --- a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java +++ b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java @@ -17,7 +17,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; import io.opentelemetry.instrumentation.api.servlet.MappingResolver; import io.opentelemetry.instrumentation.servlet.ServletAccessor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; import java.util.ArrayList; import java.util.List; import java.util.function.Function; @@ -74,7 +74,7 @@ public Instrumenter, ServletResponseContext> contextCustomizer : diff --git a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java index 19c34afae421..2b929e237aee 100644 --- a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java +++ b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java @@ -20,7 +20,7 @@ import io.opentelemetry.instrumentation.api.servlet.AppServerBridge; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; import io.opentelemetry.instrumentation.servlet.ServletAccessor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; import io.opentelemetry.javaagent.instrumentation.servlet.ServletErrorCauseExtractor; import org.apache.coyote.Request; import org.apache.coyote.Response; @@ -50,8 +50,7 @@ public static Instrumenter newInstrumente .setErrorCauseExtractor(new ServletErrorCauseExtractor<>(accessor)) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) .addAttributesExtractor(additionalAttributeExtractor) .addContextCustomizer( (context, request, attributes) -> { diff --git a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowNetAttributesExtractor.java b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowNetAttributesExtractor.java index ac278775732e..17d14fcafb32 100644 --- a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowNetAttributesExtractor.java +++ b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.undertow; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import io.undertow.server.HttpServerExchange; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; public class UndertowNetAttributesExtractor - extends InetSocketAddressNetServerAttributesExtractor { + extends InetSocketAddressNetAttributesServerExtractor { @Override public @Nullable InetSocketAddress getAddress(HttpServerExchange exchange) { diff --git a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java index dfd7cfe22f50..34a261856015 100644 --- a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java +++ b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java @@ -19,7 +19,7 @@ import io.opentelemetry.instrumentation.api.servlet.AppServerBridge; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; import io.opentelemetry.javaagent.bootstrap.undertow.UndertowActiveHandlers; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesOnStartExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; import io.undertow.server.HttpServerExchange; public final class UndertowSingletons { @@ -44,7 +44,7 @@ public final class UndertowSingletons { .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesOnStartExtractor.create(netAttributesExtractor)) + PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) .addContextCustomizer( (context, request, attributes) -> { context = ServerSpanNaming.init(context, CONTAINER); diff --git a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractor.java b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractor.java similarity index 88% rename from javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractor.java rename to javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractor.java index a9cdc686ac71..0c7117ce7040 100644 --- a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractor.java +++ b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractor.java @@ -22,7 +22,7 @@ * otel.instrumentation.common.peer-service-mapping} configuration property. The format used is a * comma-separated list of {@code host=name} pairs. */ -public final class PeerServiceAttributesOnEndExtractor +public final class PeerServiceAttributesClientExtractor extends AttributesExtractor { private static final Map JAVAAGENT_PEER_SERVICE_MAPPING = Config.get().getMap("otel.instrumentation.common.peer-service-mapping"); @@ -31,7 +31,7 @@ public final class PeerServiceAttributesOnEndExtractor private final NetAttributesClientExtractor netResponseAttributesExtractor; // visible for tests - PeerServiceAttributesOnEndExtractor( + PeerServiceAttributesClientExtractor( Map peerServiceMapping, NetAttributesClientExtractor netResponseAttributesExtractor) { this.peerServiceMapping = peerServiceMapping; @@ -39,12 +39,12 @@ public final class PeerServiceAttributesOnEndExtractor } /** - * Returns a new {@link PeerServiceAttributesOnEndExtractor} that will use the passed {@code + * Returns a new {@link PeerServiceAttributesClientExtractor} that will use the passed {@code * netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute. */ - public static PeerServiceAttributesOnEndExtractor create( + public static PeerServiceAttributesClientExtractor create( NetAttributesClientExtractor netResponseAttributesExtractor) { - return new PeerServiceAttributesOnEndExtractor<>( + return new PeerServiceAttributesClientExtractor<>( JAVAAGENT_PEER_SERVICE_MAPPING, netResponseAttributesExtractor); } diff --git a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractor.java b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractor.java similarity index 88% rename from javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractor.java rename to javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractor.java index cb74b1d8a790..5d82b3d59840 100644 --- a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractor.java +++ b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractor.java @@ -22,7 +22,7 @@ * otel.instrumentation.common.peer-service-mapping} configuration property. The format used is a * comma-separated list of {@code host=name} pairs. */ -public final class PeerServiceAttributesOnStartExtractor +public final class PeerServiceAttributesServerExtractor extends AttributesExtractor { private static final Map JAVAAGENT_PEER_SERVICE_MAPPING = Config.get().getMap("otel.instrumentation.common.peer-service-mapping"); @@ -31,7 +31,7 @@ public final class PeerServiceAttributesOnStartExtractor private final NetAttributesServerExtractor netAttributesExtractor; // visible for tests - PeerServiceAttributesOnStartExtractor( + PeerServiceAttributesServerExtractor( Map peerServiceMapping, NetAttributesServerExtractor netAttributesExtractor) { this.peerServiceMapping = peerServiceMapping; @@ -39,12 +39,12 @@ public final class PeerServiceAttributesOnStartExtractor } /** - * Returns a new {@link PeerServiceAttributesOnStartExtractor} that will use the passed {@code + * Returns a new {@link PeerServiceAttributesServerExtractor} that will use the passed {@code * netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute. */ - public static PeerServiceAttributesOnStartExtractor create( + public static PeerServiceAttributesServerExtractor create( NetAttributesServerExtractor netAttributesExtractor) { - return new PeerServiceAttributesOnStartExtractor<>( + return new PeerServiceAttributesServerExtractor<>( JAVAAGENT_PEER_SERVICE_MAPPING, netAttributesExtractor); } diff --git a/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractorTest.java b/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractorTest.java similarity index 83% rename from javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractorTest.java rename to javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractorTest.java index cfa507e25a39..469d3c8a399f 100644 --- a/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnEndExtractorTest.java +++ b/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractorTest.java @@ -24,7 +24,7 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class PeerServiceAttributesOnEndExtractorTest { +class PeerServiceAttributesClientExtractorTest { @Mock NetAttributesClientExtractor netAttributesExtractor; @Test @@ -32,8 +32,8 @@ void shouldNotSetAnyValueIfNetExtractorReturnsNulls() { // given Map peerServiceMapping = singletonMap("1.2.3.4", "myService"); - PeerServiceAttributesOnEndExtractor underTest = - new PeerServiceAttributesOnEndExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesClientExtractor underTest = + new PeerServiceAttributesClientExtractor<>(peerServiceMapping, netAttributesExtractor); // when AttributesBuilder attributes = Attributes.builder(); @@ -49,8 +49,8 @@ void shouldNotSetAnyValueIfPeerNameDoesNotMatch() { // given Map peerServiceMapping = singletonMap("example.com", "myService"); - PeerServiceAttributesOnEndExtractor underTest = - new PeerServiceAttributesOnEndExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesClientExtractor underTest = + new PeerServiceAttributesClientExtractor<>(peerServiceMapping, netAttributesExtractor); given(netAttributesExtractor.peerName(any(), any())).willReturn("example2.com"); @@ -70,8 +70,8 @@ void shouldNotSetAnyValueIfPeerIpDoesNotMatch() { // given Map peerServiceMapping = singletonMap("1.2.3.4", "myService"); - PeerServiceAttributesOnEndExtractor underTest = - new PeerServiceAttributesOnEndExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesClientExtractor underTest = + new PeerServiceAttributesClientExtractor<>(peerServiceMapping, netAttributesExtractor); given(netAttributesExtractor.peerIp(any(), any())).willReturn("1.2.3.5"); @@ -93,8 +93,8 @@ void shouldSetPeerNameIfItMatches() { peerServiceMapping.put("example.com", "myService"); peerServiceMapping.put("1.2.3.4", "someOtherService"); - PeerServiceAttributesOnEndExtractor underTest = - new PeerServiceAttributesOnEndExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesClientExtractor underTest = + new PeerServiceAttributesClientExtractor<>(peerServiceMapping, netAttributesExtractor); given(netAttributesExtractor.peerName(any(), any())).willReturn("example.com"); @@ -117,8 +117,8 @@ void shouldSetPeerIpIfItMatchesAndNameDoesNot() { peerServiceMapping.put("example.com", "myService"); peerServiceMapping.put("1.2.3.4", "someOtherService"); - PeerServiceAttributesOnEndExtractor underTest = - new PeerServiceAttributesOnEndExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesClientExtractor underTest = + new PeerServiceAttributesClientExtractor<>(peerServiceMapping, netAttributesExtractor); given(netAttributesExtractor.peerName(any(), any())).willReturn("test.com"); given(netAttributesExtractor.peerIp(any(), any())).willReturn("1.2.3.4"); diff --git a/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractorTest.java b/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractorTest.java similarity index 82% rename from javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractorTest.java rename to javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractorTest.java index 1a4eb4a75c40..8bc78b67ab53 100644 --- a/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesOnStartExtractorTest.java +++ b/javaagent-instrumentation-api/src/test/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractorTest.java @@ -24,7 +24,7 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class PeerServiceAttributesOnStartExtractorTest { +class PeerServiceAttributesServerExtractorTest { @Mock NetAttributesServerExtractor netAttributesExtractor; @Test @@ -32,8 +32,8 @@ void shouldNotSetAnyValueIfNetExtractorReturnsNulls() { // given Map peerServiceMapping = singletonMap("1.2.3.4", "myService"); - PeerServiceAttributesOnStartExtractor underTest = - new PeerServiceAttributesOnStartExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesServerExtractor underTest = + new PeerServiceAttributesServerExtractor<>(peerServiceMapping, netAttributesExtractor); // when AttributesBuilder attributes = Attributes.builder(); @@ -49,8 +49,8 @@ void shouldNotSetAnyValueIfPeerNameDoesNotMatch() { // given Map peerServiceMapping = singletonMap("example.com", "myService"); - PeerServiceAttributesOnStartExtractor underTest = - new PeerServiceAttributesOnStartExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesServerExtractor underTest = + new PeerServiceAttributesServerExtractor<>(peerServiceMapping, netAttributesExtractor); given(netAttributesExtractor.peerName(any())).willReturn("example2.com"); @@ -70,8 +70,8 @@ void shouldNotSetAnyValueIfPeerIpDoesNotMatch() { // given Map peerServiceMapping = singletonMap("1.2.3.4", "myService"); - PeerServiceAttributesOnStartExtractor underTest = - new PeerServiceAttributesOnStartExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesServerExtractor underTest = + new PeerServiceAttributesServerExtractor<>(peerServiceMapping, netAttributesExtractor); given(netAttributesExtractor.peerIp(any())).willReturn("1.2.3.5"); @@ -93,8 +93,8 @@ void shouldSetPeerNameIfItMatches() { peerServiceMapping.put("example.com", "myService"); peerServiceMapping.put("1.2.3.4", "someOtherService"); - PeerServiceAttributesOnStartExtractor underTest = - new PeerServiceAttributesOnStartExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesServerExtractor underTest = + new PeerServiceAttributesServerExtractor<>(peerServiceMapping, netAttributesExtractor); given(netAttributesExtractor.peerName(any())).willReturn("example.com"); @@ -117,8 +117,8 @@ void shouldSetPeerIpIfItMatchesAndNameDoesNot() { peerServiceMapping.put("example.com", "myService"); peerServiceMapping.put("1.2.3.4", "someOtherService"); - PeerServiceAttributesOnStartExtractor underTest = - new PeerServiceAttributesOnStartExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesServerExtractor underTest = + new PeerServiceAttributesServerExtractor<>(peerServiceMapping, netAttributesExtractor); given(netAttributesExtractor.peerName(any())).willReturn("test.com"); given(netAttributesExtractor.peerIp(any())).willReturn("1.2.3.4"); From 6730c2f6706c498a35318886b7d783d48d772d31 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Tue, 5 Oct 2021 14:10:43 -0700 Subject: [PATCH 10/26] peer.service --- .../apachedubbo/v2_7/OpenTelemetryFilter.java | 5 +- .../ApacheHttpAsyncClientSingletons.java | 5 +- .../v2_0/ApacheHttpClientSingletons.java | 5 +- .../v4_0/ApacheHttpClientSingletons.java | 5 +- .../v5_0/ApacheHttpClientSingletons.java | 5 +- .../armeria/v1_3/ArmeriaSingletons.java | 9 ++-- .../v1_9/AsyncHttpClientSingletons.java | 5 +- .../v2_0/AsyncHttpClientSingletons.java | 5 +- .../ElasticsearchRestInstrumenterFactory.java | 4 +- .../GoogleHttpClientSingletons.java | 5 +- .../grpc/v1_6/GrpcSingletons.java | 6 +-- .../HttpUrlConnectionSingletons.java | 5 +- .../httpclient/JdkHttpClientSingletons.java | 5 +- .../v1_1/JaxRsClientSingletons.java | 5 +- .../v2_0/JaxRsClientSingletons.java | 5 +- .../v2_0/ResteasyClientSingletons.java | 5 +- .../instrumentation/jdbc/JdbcSingletons.java | 5 +- .../jedis/v1_4/JedisSingletons.java | 5 +- .../jedis/v3_0/JedisSingletons.java | 5 +- .../v9_2/JettyHttpClientSingletons.java | 6 +-- .../lettuce/v4_0/LettuceSingletons.java | 4 +- .../lettuce/v5_0/LettuceSingletons.java | 4 +- .../LibertyDispatcherSingletons.java | 5 +- .../okhttp/v2_2/OkHttp2Singletons.java | 5 +- .../okhttp/v3_0/OkHttp3Singletons.java | 4 +- .../playws/PlayWsClientSingletons.java | 5 +- .../servlet/ServletInstrumenterBuilder.java | 5 +- .../ServletNetAttributesExtractor.java | 4 +- .../common/TomcatInstrumenterBuilder.java | 4 +- .../undertow/UndertowSingletons.java | 5 +- .../PeerServiceAttributesClientExtractor.java | 28 +---------- .../PeerServiceAttributesExtractor.java | 50 +++++++++++++++++++ .../PeerServiceAttributesServerExtractor.java | 28 +---------- 33 files changed, 118 insertions(+), 138 deletions(-) create mode 100644 javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java diff --git a/instrumentation/apache-dubbo-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachedubbo/v2_7/OpenTelemetryFilter.java b/instrumentation/apache-dubbo-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachedubbo/v2_7/OpenTelemetryFilter.java index 2b2befb10032..bf9d6c4636f2 100644 --- a/instrumentation/apache-dubbo-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachedubbo/v2_7/OpenTelemetryFilter.java +++ b/instrumentation/apache-dubbo-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachedubbo/v2_7/OpenTelemetryFilter.java @@ -8,7 +8,7 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.apachedubbo.v2_7.DubboTracing; import io.opentelemetry.instrumentation.apachedubbo.v2_7.internal.DubboNetServerAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import org.apache.dubbo.common.extension.Activate; import org.apache.dubbo.rpc.Filter; import org.apache.dubbo.rpc.Invocation; @@ -25,8 +25,7 @@ public OpenTelemetryFilter() { new DubboNetServerAttributesExtractor(); delegate = DubboTracing.newBuilder(GlobalOpenTelemetry.get()) - .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .build() .newFilter(); } 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 345f81196b67..c28a86c0264e 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 @@ -13,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import org.apache.http.HttpResponse; public final class ApacheHttpAsyncClientSingletons { @@ -37,8 +37,7 @@ public final class ApacheHttpAsyncClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } 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 4e53a2d95078..2bc0896b42e9 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 @@ -13,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import org.apache.commons.httpclient.HttpMethod; public final class ApacheHttpClientSingletons { @@ -37,8 +37,7 @@ public final class ApacheHttpClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } 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 fcb764bf31a6..be172f12934d 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 @@ -13,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import org.apache.http.HttpResponse; public final class ApacheHttpClientSingletons { @@ -37,8 +37,7 @@ public final class ApacheHttpClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } 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 2c0576569e93..26ffb50bc155 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 @@ -13,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.HttpResponse; @@ -38,8 +38,7 @@ public final class ApacheHttpClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } diff --git a/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java b/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java index fb57cdc2203b..7d837e8e4769 100644 --- a/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java +++ b/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java @@ -12,7 +12,7 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.armeria.v1_3.ArmeriaTracing; import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaNetClientAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesClientExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import java.util.function.Function; // Holds singleton references to decorators to match against during suppression. @@ -25,13 +25,12 @@ public final class ArmeriaSingletons { static { // TODO (trask) split ArmeriaNetAttributesExtractor into client/server // (and move into ArmeriaTracingBuilder?) - PeerServiceAttributesClientExtractor - peerServiceAttributesClientExtractor = - PeerServiceAttributesClientExtractor.create(new ArmeriaNetClientAttributesExtractor()); + PeerServiceAttributesExtractor peerServiceAttributesExtractor = + PeerServiceAttributesExtractor.create(new ArmeriaNetClientAttributesExtractor()); ArmeriaTracing tracing = ArmeriaTracing.newBuilder(GlobalOpenTelemetry.get()) - .addAttributeExtractor(peerServiceAttributesClientExtractor) + .addAttributeExtractor(peerServiceAttributesExtractor) .build(); CLIENT_DECORATOR = tracing.newClientDecorator(); 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 a53be7b55f6e..b222d15921b3 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 @@ -15,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; public final class AsyncHttpClientSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.async-http-client-1.9"; @@ -38,8 +38,7 @@ public final class AsyncHttpClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } 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 d8a6e113e083..4580d08865dd 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 @@ -14,7 +14,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesClientExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import org.asynchttpclient.Response; public final class AsyncHttpClientSingletons { @@ -38,8 +38,7 @@ public final class AsyncHttpClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesClientExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addAttributesExtractor(new AsyncHttpClientAdditionalAttributesExtractor()) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); 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 b62e1aa7ea47..fde1dd18d67c 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 @@ -10,7 +10,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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesClientExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import org.elasticsearch.client.Response; public final class ElasticsearchRestInstrumenterFactory { @@ -26,7 +26,7 @@ public static Instrumenter create(String instrumentationName) GlobalOpenTelemetry.get(), instrumentationName, spanNameExtractor) .addAttributesExtractor(attributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesClientExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .newInstrumenter(SpanKindExtractor.alwaysClient()); } 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 6e7667ab149d..f9899509b19f 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 @@ -15,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; public class GoogleHttpClientSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.google-http-client-1.19"; @@ -38,8 +38,7 @@ public class GoogleHttpClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } diff --git a/instrumentation/grpc-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grpc/v1_6/GrpcSingletons.java b/instrumentation/grpc-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grpc/v1_6/GrpcSingletons.java index f47edc4d893c..39577333e024 100644 --- a/instrumentation/grpc-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grpc/v1_6/GrpcSingletons.java +++ b/instrumentation/grpc-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grpc/v1_6/GrpcSingletons.java @@ -15,7 +15,7 @@ import io.opentelemetry.instrumentation.grpc.v1_6.GrpcTracing; import io.opentelemetry.instrumentation.grpc.v1_6.internal.ContextStorageBridge; import io.opentelemetry.instrumentation.grpc.v1_6.internal.GrpcNetServerAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; // Holds singleton references. public final class GrpcSingletons { @@ -29,8 +29,8 @@ public final class GrpcSingletons { static { boolean experimentalSpanAttributes = Config.get().getBoolean("otel.instrumentation.grpc.experimental-span-attributes", false); - PeerServiceAttributesServerExtractor peerServiceAttributesExtractor = - PeerServiceAttributesServerExtractor.create(new GrpcNetServerAttributesExtractor()); + PeerServiceAttributesExtractor peerServiceAttributesExtractor = + PeerServiceAttributesExtractor.create(new GrpcNetServerAttributesExtractor()); GrpcTracing tracing = GrpcTracing.newBuilder(GlobalOpenTelemetry.get()) 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 9393cb8a06a1..dc2491112988 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,7 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import java.net.HttpURLConnection; public class HttpUrlConnectionSingletons { @@ -31,8 +31,7 @@ public class HttpUrlConnectionSingletons { spanNameExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .newClientInstrumenter(SETTER); } 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 0a8015ffd1f7..3af0c0d2b5a4 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 @@ -12,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import java.net.http.HttpRequest; import java.net.http.HttpResponse; @@ -36,8 +36,7 @@ public class JdkHttpClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(SETTER); } 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 253fe49813a6..f0b06adb7af2 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 @@ -15,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; public class JaxRsClientSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jaxrs-client-1.1"; @@ -38,8 +38,7 @@ public class JaxRsClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new InjectAdapter()); } 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 31e058252e51..9cd98be86674 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 @@ -14,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import javax.ws.rs.ProcessingException; import javax.ws.rs.client.ClientRequestContext; import javax.ws.rs.client.ClientResponseContext; @@ -47,8 +47,7 @@ public class JaxRsClientSingletons { }) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new InjectAdapter()); } 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 bc1ef46c9005..09a879432989 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 @@ -14,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import javax.ws.rs.ProcessingException; import javax.ws.rs.core.Response; import org.jboss.resteasy.client.jaxrs.internal.ClientInvocation; @@ -48,8 +48,7 @@ public class ResteasyClientSingletons { }) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new ResteasyInjectAdapter()); } 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 171c78eee56b..6ce589beb462 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 @@ -14,7 +14,7 @@ import io.opentelemetry.instrumentation.jdbc.internal.DbRequest; import io.opentelemetry.instrumentation.jdbc.internal.JdbcAttributesExtractor; import io.opentelemetry.instrumentation.jdbc.internal.JdbcNetAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; public final class JdbcSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jdbc"; @@ -31,8 +31,7 @@ public final class JdbcSingletons { GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanName) .addAttributesExtractor(dbAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .newInstrumenter(SpanKindExtractor.alwaysClient()); } 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 68dc58d3efb6..a512b53480d4 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 @@ -11,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; public final class JedisSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jedis-1.4"; @@ -29,8 +29,7 @@ public final class JedisSingletons { GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanName) .addAttributesExtractor(attributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .newInstrumenter(SpanKindExtractor.alwaysClient()); } 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 faa7fe1f9779..cfbce45fbda6 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 @@ -11,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; public final class JedisSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jedis-3.0"; @@ -29,8 +29,7 @@ public final class JedisSingletons { GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanName) .addAttributesExtractor(attributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .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 7f0f17ae87a4..ee09856fb565 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.jetty.httpclient.v9_2.internal.JettyClientInstrumenterBuilder; import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal.JettyHttpClientNetAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.api.Response; @@ -23,8 +23,8 @@ private JettyHttpClientSingletons() {} JettyClientInstrumenterBuilder builder = new JettyClientInstrumenterBuilder(GlobalOpenTelemetry.get()); - PeerServiceAttributesServerExtractor peerServiceAttributesExtractor = - PeerServiceAttributesServerExtractor.create(new JettyHttpClientNetAttributesExtractor()); + PeerServiceAttributesExtractor peerServiceAttributesExtractor = + PeerServiceAttributesExtractor.create(new JettyHttpClientNetAttributesExtractor()); INSTRUMENTER = builder.addAttributeExtractor(peerServiceAttributesExtractor).build(); } 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 b6dd017144ca..d1692c27922a 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 @@ -15,7 +15,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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; public final class LettuceSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.lettuce-4.0"; @@ -45,7 +45,7 @@ public final class LettuceSingletons { GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, redisUri -> "CONNECT") .addAttributesExtractor(connectNetAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(connectNetAttributesExtractor)) + PeerServiceAttributesExtractor.create(connectNetAttributesExtractor)) .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/LettuceSingletons.java b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceSingletons.java index 3bd998117db2..b5c73a16ac65 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 @@ -15,7 +15,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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; public final class LettuceSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.lettuce-5.0"; @@ -45,7 +45,7 @@ public final class LettuceSingletons { GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, redisUri -> "CONNECT") .addAttributesExtractor(connectNetAttributesExtractor) .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(connectNetAttributesExtractor)) + PeerServiceAttributesExtractor.create(connectNetAttributesExtractor)) .addAttributesExtractor(new LettuceConnectAttributesExtractor()) .newInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java index 9316fa80b0d0..8a247d9a35d6 100644 --- a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java +++ b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java @@ -17,7 +17,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; public final class LibertyDispatcherSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.liberty-dispatcher"; @@ -40,8 +40,7 @@ public final class LibertyDispatcherSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addContextCustomizer( (context, request, attributes) -> ServerSpanNaming.init(context, CONTAINER)) .addRequestMetrics(HttpServerMetrics.get()) 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 e523a54e4df2..b3206a1b3217 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 @@ -20,7 +20,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; public final class OkHttp2Singletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.okhttp-2.2"; @@ -46,8 +46,7 @@ public final class OkHttp2Singletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .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 9fd7c8c4d57f..5c8a76dc10ba 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.okhttp.v3_0.OkHttpTracing; import io.opentelemetry.instrumentation.okhttp.v3_0.internal.OkHttpNetAttributesExtractor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; 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.newBuilder(GlobalOpenTelemetry.get()) .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(new OkHttpNetAttributesExtractor())) + PeerServiceAttributesExtractor.create(new OkHttpNetAttributesExtractor())) .build() .newInterceptor(); 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 feb09c109d2a..bcd95b3d2d7e 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 @@ -13,7 +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.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesClientExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import play.shaded.ahc.org.asynchttpclient.Request; import play.shaded.ahc.org.asynchttpclient.Response; @@ -38,8 +38,7 @@ public class PlayWsClientSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesClientExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addRequestMetrics(HttpClientMetrics.get()) .newClientInstrumenter(new HttpHeaderSetter()); } diff --git a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java index 85f8863b4779..01022a75b367 100644 --- a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java +++ b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java @@ -17,7 +17,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; import io.opentelemetry.instrumentation.api.servlet.MappingResolver; import io.opentelemetry.instrumentation.servlet.ServletAccessor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import java.util.ArrayList; import java.util.List; import java.util.function.Function; @@ -73,8 +73,7 @@ public Instrumenter, ServletResponseContext> contextCustomizer : diff --git a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesExtractor.java b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesExtractor.java index 34ca02aaa59b..dd8e7d313f83 100644 --- a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesExtractor.java +++ b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesExtractor.java @@ -5,12 +5,12 @@ package io.opentelemetry.javaagent.instrumentation.servlet; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesOnStartExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.instrumentation.servlet.ServletAccessor; import org.checkerframework.checker.nullness.qual.Nullable; public class ServletNetAttributesExtractor - extends NetAttributesOnStartExtractor< + extends NetAttributesServerExtractor< ServletRequestContext, ServletResponseContext> { private final ServletAccessor accessor; diff --git a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java index 2b929e237aee..995b20a56a55 100644 --- a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java +++ b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java @@ -20,7 +20,7 @@ import io.opentelemetry.instrumentation.api.servlet.AppServerBridge; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; import io.opentelemetry.instrumentation.servlet.ServletAccessor; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import io.opentelemetry.javaagent.instrumentation.servlet.ServletErrorCauseExtractor; import org.apache.coyote.Request; import org.apache.coyote.Response; @@ -50,7 +50,7 @@ public static Instrumenter newInstrumente .setErrorCauseExtractor(new ServletErrorCauseExtractor<>(accessor)) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addAttributesExtractor(additionalAttributeExtractor) .addContextCustomizer( (context, request, attributes) -> { diff --git a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java index 34a261856015..31dbb0116a33 100644 --- a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java +++ b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java @@ -19,7 +19,7 @@ import io.opentelemetry.instrumentation.api.servlet.AppServerBridge; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; import io.opentelemetry.javaagent.bootstrap.undertow.UndertowActiveHandlers; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesServerExtractor; +import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import io.undertow.server.HttpServerExchange; public final class UndertowSingletons { @@ -43,8 +43,7 @@ public final class UndertowSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor( - PeerServiceAttributesServerExtractor.create(netAttributesExtractor)) + .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addContextCustomizer( (context, request, attributes) -> { context = ServerSpanNaming.init(context, CONTAINER); diff --git a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractor.java b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractor.java index 0c7117ce7040..d597682fe948 100644 --- a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractor.java +++ b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractor.java @@ -6,31 +6,17 @@ package io.opentelemetry.javaagent.instrumentation.api.instrumenter; import io.opentelemetry.api.common.AttributesBuilder; -import io.opentelemetry.instrumentation.api.config.Config; -import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.Map; import org.checkerframework.checker.nullness.qual.Nullable; -/** - * Extractor of the {@code peer.service} span attribute, described in the - * specification. - * - *

Peer service name mappings can be configured using the {@code - * otel.instrumentation.common.peer-service-mapping} configuration property. The format used is a - * comma-separated list of {@code host=name} pairs. - */ -public final class PeerServiceAttributesClientExtractor - extends AttributesExtractor { - private static final Map JAVAAGENT_PEER_SERVICE_MAPPING = - Config.get().getMap("otel.instrumentation.common.peer-service-mapping"); +final class PeerServiceAttributesClientExtractor + extends PeerServiceAttributesExtractor { private final Map peerServiceMapping; private final NetAttributesClientExtractor netResponseAttributesExtractor; - // visible for tests PeerServiceAttributesClientExtractor( Map peerServiceMapping, NetAttributesClientExtractor netResponseAttributesExtractor) { @@ -38,16 +24,6 @@ public final class PeerServiceAttributesClientExtractor this.netResponseAttributesExtractor = netResponseAttributesExtractor; } - /** - * Returns a new {@link PeerServiceAttributesClientExtractor} that will use the passed {@code - * netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute. - */ - public static PeerServiceAttributesClientExtractor create( - NetAttributesClientExtractor netResponseAttributesExtractor) { - return new PeerServiceAttributesClientExtractor<>( - JAVAAGENT_PEER_SERVICE_MAPPING, netResponseAttributesExtractor); - } - @Override protected void onStart(AttributesBuilder attributes, REQUEST request) {} diff --git a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java new file mode 100644 index 000000000000..c77c2cba8a47 --- /dev/null +++ b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java @@ -0,0 +1,50 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.javaagent.instrumentation.api.instrumenter; + +import io.opentelemetry.instrumentation.api.config.Config; +import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import java.util.Map; + +/** + * Extractor of the {@code peer.service} span attribute, described in the + * specification. + * + *

Peer service name mappings can be configured using the {@code + * otel.instrumentation.common.peer-service-mapping} configuration property. The format used is a + * comma-separated list of {@code host=name} pairs. + */ +public abstract class PeerServiceAttributesExtractor + extends AttributesExtractor { + private static final Map JAVAAGENT_PEER_SERVICE_MAPPING = + Config.get().getMap("otel.instrumentation.common.peer-service-mapping"); + + // package-protected to allow only subclasses in this package + PeerServiceAttributesExtractor() {} + + /** + * Returns a new {@link AttributesExtractor} that will use the passed {@code + * netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute. + */ + public static PeerServiceAttributesExtractor create( + NetAttributesClientExtractor netAttributesExtractor) { + return new PeerServiceAttributesClientExtractor<>( + JAVAAGENT_PEER_SERVICE_MAPPING, netAttributesExtractor); + } + + /** + * Returns a new {@link PeerServiceAttributesExtractor} that will use the passed {@code + * netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute. + */ + public static PeerServiceAttributesExtractor create( + NetAttributesServerExtractor netAttributesExtractor) { + return new PeerServiceAttributesServerExtractor<>( + JAVAAGENT_PEER_SERVICE_MAPPING, netAttributesExtractor); + } +} diff --git a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractor.java b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractor.java index 5d82b3d59840..d2a40f0c0398 100644 --- a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractor.java +++ b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractor.java @@ -6,31 +6,17 @@ package io.opentelemetry.javaagent.instrumentation.api.instrumenter; import io.opentelemetry.api.common.AttributesBuilder; -import io.opentelemetry.instrumentation.api.config.Config; -import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.Map; import org.checkerframework.checker.nullness.qual.Nullable; -/** - * Extractor of the {@code peer.service} span attribute, described in the - * specification. - * - *

Peer service name mappings can be configured using the {@code - * otel.instrumentation.common.peer-service-mapping} configuration property. The format used is a - * comma-separated list of {@code host=name} pairs. - */ -public final class PeerServiceAttributesServerExtractor - extends AttributesExtractor { - private static final Map JAVAAGENT_PEER_SERVICE_MAPPING = - Config.get().getMap("otel.instrumentation.common.peer-service-mapping"); +final class PeerServiceAttributesServerExtractor + extends PeerServiceAttributesExtractor { private final Map peerServiceMapping; private final NetAttributesServerExtractor netAttributesExtractor; - // visible for tests PeerServiceAttributesServerExtractor( Map peerServiceMapping, NetAttributesServerExtractor netAttributesExtractor) { @@ -38,16 +24,6 @@ public final class PeerServiceAttributesServerExtractor this.netAttributesExtractor = netAttributesExtractor; } - /** - * Returns a new {@link PeerServiceAttributesServerExtractor} that will use the passed {@code - * netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute. - */ - public static PeerServiceAttributesServerExtractor create( - NetAttributesServerExtractor netAttributesExtractor) { - return new PeerServiceAttributesServerExtractor<>( - JAVAAGENT_PEER_SERVICE_MAPPING, netAttributesExtractor); - } - @Override protected void onStart(AttributesBuilder attributes, REQUEST request) { String peerName = netAttributesExtractor.peerName(request); From 255395a4353853c875681b68c7c688cdad76de99 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 6 Oct 2021 10:20:23 -0700 Subject: [PATCH 11/26] Feedback --- ...etAddressNetAttributesClientExtractor.java | 13 ++----- ...etAddressNetAttributesServerExtractor.java | 5 --- .../net/NetAttributesServerExtractor.java | 15 -------- ...dressNetAttributesClientExtractorTest.java | 38 +++++++++++++------ ...dressNetAttributesServerExtractorTest.java | 30 +++++++++++---- .../net/NetAttributesClientExtractorTest.java | 10 +++++ .../net/NetAttributesServerExtractorTest.java | 20 ++++++++++ .../v1_4/JedisNetAttributesExtractor.java | 12 +++--- 8 files changed, 90 insertions(+), 53 deletions(-) diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesClientExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesClientExtractor.java index 2f81dca4d9e9..c42dae3e0588 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesClientExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesClientExtractor.java @@ -19,17 +19,12 @@ public abstract class InetSocketAddressNetAttributesClientExtractor extends NetAttributesClientExtractor { - /** - * This method will be called twice: both when the request starts ({@code response} is always null - * then) and when the response ends. This way it is possible to capture net attributes in both - * phases of processing. - */ @Nullable - public abstract InetSocketAddress getAddress(REQUEST request, RESPONSE response); + public abstract InetSocketAddress getAddress(REQUEST request, @Nullable RESPONSE response); @Override @Nullable - public final String peerName(REQUEST request, RESPONSE response) { + public final String peerName(REQUEST request, @Nullable RESPONSE response) { InetSocketAddress address = getAddress(request, response); if (address == null) { return null; @@ -42,7 +37,7 @@ public final String peerName(REQUEST request, RESPONSE response) { @Override @Nullable - public final Integer peerPort(REQUEST request, RESPONSE response) { + public final Integer peerPort(REQUEST request, @Nullable RESPONSE response) { InetSocketAddress address = getAddress(request, response); if (address == null) { return null; @@ -52,7 +47,7 @@ public final Integer peerPort(REQUEST request, RESPONSE response) { @Override @Nullable - public final String peerIp(REQUEST request, RESPONSE response) { + public final String peerIp(REQUEST request, @Nullable RESPONSE response) { InetSocketAddress address = getAddress(request, response); if (address == null) { return null; diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractor.java index a627c8aa7c16..67b1b26907db 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractor.java @@ -19,11 +19,6 @@ public abstract class InetSocketAddressNetAttributesServerExtractor extends NetAttributesServerExtractor { - /** - * This method will be called twice: both when the request starts ({@code response} is always null - * then) and when the response ends. This way it is possible to capture net attributes in both - * phases of processing. - */ @Nullable public abstract InetSocketAddress getAddress(REQUEST request); diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractor.java index e745911c92e1..2e9873dbc1f0 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractor.java @@ -47,27 +47,12 @@ protected final void onEnd( @Nullable public abstract String transport(REQUEST request); - /** - * This method will be called twice: both when the request starts ({@code response} is always null - * then) and when the response ends. This way it is possible to capture net attributes in both - * phases of processing. - */ @Nullable public abstract String peerName(REQUEST request); - /** - * This method will be called twice: both when the request starts ({@code response} is always null - * then) and when the response ends. This way it is possible to capture net attributes in both - * phases of processing. - */ @Nullable public abstract Integer peerPort(REQUEST request); - /** - * This method will be called twice: both when the request starts ({@code response} is always null - * then) and when the response ends. This way it is possible to capture net attributes in both - * phases of processing. - */ @Nullable public abstract String peerIp(REQUEST request); } diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesClientExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesClientExtractorTest.java index f5a5e2644c87..da5b50022b1d 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesClientExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesClientExtractorTest.java @@ -47,37 +47,53 @@ void noInetSocketAddress() { @Test void fullAddress() { // given - InetSocketAddress address = new InetSocketAddress("github.com", 123); - assertThat(address.getAddress().getHostAddress()).isNotNull(); + InetSocketAddress request = new InetSocketAddress("github.com", 123); + assertThat(request.getAddress().getHostAddress()).isNotNull(); + + InetSocketAddress response = new InetSocketAddress("api.github.com", 456); + assertThat(request.getAddress().getHostAddress()).isNotNull(); // when + AttributesBuilder startAttributes = Attributes.builder(); + extractor.onStart(startAttributes, request); + AttributesBuilder endAttributes = Attributes.builder(); - extractor.onEnd(endAttributes, null, address, null); + extractor.onEnd(endAttributes, request, response, null); // then + assertThat(startAttributes.build()).isEmpty(); + assertThat(endAttributes.build()) .containsOnly( entry(SemanticAttributes.NET_TRANSPORT, SemanticAttributes.NetTransportValues.IP_TCP), - entry(SemanticAttributes.NET_PEER_IP, address.getAddress().getHostAddress()), - entry(SemanticAttributes.NET_PEER_NAME, "github.com"), - entry(SemanticAttributes.NET_PEER_PORT, 123L)); + entry(SemanticAttributes.NET_PEER_IP, response.getAddress().getHostAddress()), + entry(SemanticAttributes.NET_PEER_NAME, "api.github.com"), + entry(SemanticAttributes.NET_PEER_PORT, 456L)); } @Test void unresolved() { // given - InetSocketAddress address = InetSocketAddress.createUnresolved("github.com", 123); - assertThat(address.getAddress()).isNull(); + InetSocketAddress request = InetSocketAddress.createUnresolved("github.com", 123); + assertThat(request.getAddress()).isNull(); + + InetSocketAddress response = InetSocketAddress.createUnresolved("api.github.com", 456); + assertThat(request.getAddress()).isNull(); // when + AttributesBuilder startAttributes = Attributes.builder(); + extractor.onStart(startAttributes, request); + AttributesBuilder endAttributes = Attributes.builder(); - extractor.onEnd(endAttributes, null, address, null); + extractor.onEnd(endAttributes, request, response, null); // then + assertThat(startAttributes.build()).isEmpty(); + assertThat(endAttributes.build()) .containsOnly( entry(SemanticAttributes.NET_TRANSPORT, SemanticAttributes.NetTransportValues.IP_TCP), - entry(SemanticAttributes.NET_PEER_NAME, "github.com"), - entry(SemanticAttributes.NET_PEER_PORT, 123L)); + entry(SemanticAttributes.NET_PEER_NAME, "api.github.com"), + entry(SemanticAttributes.NET_PEER_PORT, 456L)); } } diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractorTest.java index e9b02ae34851..dba40f7243e6 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractorTest.java @@ -46,31 +46,45 @@ void noInetSocketAddress() { @Test void fullAddress() { // given - InetSocketAddress address = new InetSocketAddress("github.com", 123); - assertThat(address.getAddress().getHostAddress()).isNotNull(); + InetSocketAddress request = new InetSocketAddress("github.com", 123); + assertThat(request.getAddress().getHostAddress()).isNotNull(); + + InetSocketAddress response = new InetSocketAddress("api.github.com", 456); + assertThat(request.getAddress().getHostAddress()).isNotNull(); // when AttributesBuilder startAttributes = Attributes.builder(); - extractor.onStart(startAttributes, address); + extractor.onStart(startAttributes, request); + + AttributesBuilder endAttributes = Attributes.builder(); + extractor.onEnd(endAttributes, request, response, null); // then assertThat(startAttributes.build()) .containsOnly( entry(SemanticAttributes.NET_TRANSPORT, SemanticAttributes.NetTransportValues.IP_TCP), - entry(SemanticAttributes.NET_PEER_IP, address.getAddress().getHostAddress()), + entry(SemanticAttributes.NET_PEER_IP, request.getAddress().getHostAddress()), entry(SemanticAttributes.NET_PEER_NAME, "github.com"), entry(SemanticAttributes.NET_PEER_PORT, 123L)); + + assertThat(endAttributes.build()).isEmpty(); } @Test void unresolved() { // given - InetSocketAddress address = InetSocketAddress.createUnresolved("github.com", 123); - assertThat(address.getAddress()).isNull(); + InetSocketAddress request = InetSocketAddress.createUnresolved("github.com", 123); + assertThat(request.getAddress()).isNull(); + + InetSocketAddress response = InetSocketAddress.createUnresolved("api.github.com", 456); + assertThat(request.getAddress()).isNull(); // when AttributesBuilder startAttributes = Attributes.builder(); - extractor.onStart(startAttributes, address); + extractor.onStart(startAttributes, request); + + AttributesBuilder endAttributes = Attributes.builder(); + extractor.onEnd(endAttributes, request, response, null); // then assertThat(startAttributes.build()) @@ -78,5 +92,7 @@ void unresolved() { entry(SemanticAttributes.NET_TRANSPORT, SemanticAttributes.NetTransportValues.IP_TCP), entry(SemanticAttributes.NET_PEER_NAME, "github.com"), entry(SemanticAttributes.NET_PEER_PORT, 123L)); + + assertThat(endAttributes.build()).isEmpty(); } } diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractorTest.java index ea7ec066b75b..cebebd1f787a 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractorTest.java @@ -67,10 +67,15 @@ void normal() { TestNetAttributesClientExtractor extractor = new TestNetAttributesClientExtractor(); // when + AttributesBuilder startAttributes = Attributes.builder(); + extractor.onStart(startAttributes, request); + AttributesBuilder endAttributes = Attributes.builder(); extractor.onEnd(endAttributes, request, response, null); // then + assertThat(startAttributes.build()).isEmpty(); + assertThat(endAttributes.build()) .containsOnly( entry(SemanticAttributes.NET_PEER_NAME, "opentelemetry.io"), @@ -95,10 +100,15 @@ public void doesNotSetDuplicateAttributes() { TestNetAttributesClientExtractor extractor = new TestNetAttributesClientExtractor(); // when + AttributesBuilder startAttributes = Attributes.builder(); + extractor.onStart(startAttributes, request); + AttributesBuilder endAttributes = Attributes.builder(); extractor.onEnd(endAttributes, request, response, null); // then + assertThat(startAttributes.build()).isEmpty(); + assertThat(endAttributes.build()) .containsOnly( entry(SemanticAttributes.NET_PEER_PORT, 42L), diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractorTest.java index 7b091634fd13..d69abb7bd7ca 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractorTest.java @@ -50,12 +50,20 @@ void normal() { request.put("peerPort", "123"); request.put("peerIp", "1.2.3.4"); + Map response = new HashMap<>(); + response.put("peerName", "opentelemetry.io"); + response.put("peerPort", "42"); + response.put("peerIp", "4.3.2.1"); + TestNetAttributesServerExtractor extractor = new TestNetAttributesServerExtractor(); // when AttributesBuilder startAttributes = Attributes.builder(); extractor.onStart(startAttributes, request); + AttributesBuilder endAttributes = Attributes.builder(); + extractor.onEnd(endAttributes, request, response, null); + // then assertThat(startAttributes.build()) .containsOnly( @@ -63,6 +71,8 @@ void normal() { entry(SemanticAttributes.NET_PEER_NAME, "github.com"), entry(SemanticAttributes.NET_PEER_PORT, 123L), entry(SemanticAttributes.NET_PEER_IP, "1.2.3.4")); + + assertThat(endAttributes.build()).isEmpty(); } @Test @@ -74,17 +84,27 @@ public void doesNotSetDuplicateAttributes() { request.put("peerIp", "1.2.3.4"); request.put("peerPort", "123"); + Map response = new HashMap<>(); + response.put("peerName", "4.3.2.1"); + response.put("peerPort", "42"); + response.put("peerIp", "4.3.2.1"); + TestNetAttributesServerExtractor extractor = new TestNetAttributesServerExtractor(); // when AttributesBuilder startAttributes = Attributes.builder(); extractor.onStart(startAttributes, request); + AttributesBuilder endAttributes = Attributes.builder(); + extractor.onEnd(endAttributes, request, response, null); + // then assertThat(startAttributes.build()) .containsOnly( entry(SemanticAttributes.NET_TRANSPORT, "TCP"), entry(SemanticAttributes.NET_PEER_PORT, 123L), entry(SemanticAttributes.NET_PEER_IP, "1.2.3.4")); + + assertThat(endAttributes.build()).isEmpty(); } } 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/JedisNetAttributesExtractor.java index 2c5bd09b82d8..40800d8d3210 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/JedisNetAttributesExtractor.java @@ -5,30 +5,30 @@ package io.opentelemetry.javaagent.instrumentation.jedis.v1_4; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; import org.checkerframework.checker.nullness.qual.Nullable; -final class JedisNetAttributesExtractor extends NetAttributesServerExtractor { +final class JedisNetAttributesExtractor extends NetAttributesClientExtractor { @Override @Nullable - public String transport(JedisRequest request) { + public String transport(JedisRequest request, @Nullable Void unused) { return null; } @Override - public String peerName(JedisRequest request) { + public String peerName(JedisRequest request, @Nullable Void unused) { return request.getConnection().getHost(); } @Override - public Integer peerPort(JedisRequest request) { + public Integer peerPort(JedisRequest request, @Nullable Void unused) { return request.getConnection().getPort(); } @Override @Nullable - public String peerIp(JedisRequest request) { + public String peerIp(JedisRequest request, @Nullable Void unused) { return null; } } From 32d1780218d428962636da8fc12acb2addb0ab65 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 6 Oct 2021 12:58:50 -0700 Subject: [PATCH 12/26] peer.service is only for clients --- .../PeerServiceAttributesClientExtractor.java | 53 ------------------ .../PeerServiceAttributesExtractor.java | 55 ++++++++++++++----- .../PeerServiceAttributesServerExtractor.java | 53 ------------------ 3 files changed, 42 insertions(+), 119 deletions(-) delete mode 100644 instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractor.java delete mode 100644 instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractor.java diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractor.java deleted file mode 100644 index dc2152352f5e..000000000000 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractor.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.instrumentation.api.instrumenter; - -import io.opentelemetry.api.common.AttributesBuilder; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; -import java.util.Map; -import org.checkerframework.checker.nullness.qual.Nullable; - -final class PeerServiceAttributesClientExtractor - extends PeerServiceAttributesExtractor { - - private final Map peerServiceMapping; - private final NetAttributesClientExtractor netResponseAttributesExtractor; - - PeerServiceAttributesClientExtractor( - Map peerServiceMapping, - NetAttributesClientExtractor netResponseAttributesExtractor) { - this.peerServiceMapping = peerServiceMapping; - this.netResponseAttributesExtractor = netResponseAttributesExtractor; - } - - @Override - protected void onStart(AttributesBuilder attributes, REQUEST request) {} - - @Override - protected void onEnd( - AttributesBuilder attributes, - REQUEST request, - @Nullable RESPONSE response, - @Nullable Throwable error) { - String peerName = netResponseAttributesExtractor.peerName(request, response); - String peerService = mapToPeerService(peerName); - if (peerService == null) { - String peerIp = netResponseAttributesExtractor.peerIp(request, response); - peerService = mapToPeerService(peerIp); - } - if (peerService != null) { - attributes.put(SemanticAttributes.PEER_SERVICE, peerService); - } - } - - private String mapToPeerService(String endpoint) { - if (endpoint == null) { - return null; - } - return peerServiceMapping.get(endpoint); - } -} 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 903fdefe0edb..0a8240b21cec 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 @@ -5,10 +5,12 @@ package io.opentelemetry.instrumentation.api.instrumenter; +import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.instrumentation.api.config.Config; import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.Map; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Extractor of the {@code peer.service} span attribute, described in +public final class PeerServiceAttributesExtractor extends AttributesExtractor { private static final Map JAVAAGENT_PEER_SERVICE_MAPPING = Config.get().getMap("otel.instrumentation.common.peer-service-mapping"); - // package-protected to allow only subclasses in this package - PeerServiceAttributesExtractor() {} + private final Map peerServiceMapping; + private final NetAttributesClientExtractor netAttributesExtractor; - /** - * Returns a new {@link AttributesExtractor} that will use the passed {@code - * netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute. - */ - public static PeerServiceAttributesExtractor create( + // visible for tests + PeerServiceAttributesExtractor( + Map peerServiceMapping, NetAttributesClientExtractor netAttributesExtractor) { - return new PeerServiceAttributesClientExtractor<>( - JAVAAGENT_PEER_SERVICE_MAPPING, netAttributesExtractor); + this.peerServiceMapping = peerServiceMapping; + this.netAttributesExtractor = netAttributesExtractor; } /** @@ -42,8 +42,37 @@ public static PeerServiceAttributesExtractor PeerServiceAttributesExtractor create( - NetAttributesServerExtractor netAttributesExtractor) { - return new PeerServiceAttributesServerExtractor<>( + NetAttributesClientExtractor netAttributesExtractor) { + return new PeerServiceAttributesExtractor<>( JAVAAGENT_PEER_SERVICE_MAPPING, netAttributesExtractor); } + + @Override + protected void onStart(AttributesBuilder attributes, REQUEST request) { + onEnd(attributes, request, null, null); + } + + @Override + protected void onEnd( + AttributesBuilder attributes, + REQUEST request, + @Nullable RESPONSE response, + @Nullable Throwable error) { + String peerName = netAttributesExtractor.peerName(request, response); + String peerService = mapToPeerService(peerName); + if (peerService == null) { + String peerIp = netAttributesExtractor.peerIp(request, response); + peerService = mapToPeerService(peerIp); + } + if (peerService != null) { + attributes.put(SemanticAttributes.PEER_SERVICE, peerService); + } + } + + private String mapToPeerService(String endpoint) { + if (endpoint == null) { + return null; + } + return peerServiceMapping.get(endpoint); + } } diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractor.java deleted file mode 100644 index 9a3e017122bc..000000000000 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractor.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.instrumentation.api.instrumenter; - -import io.opentelemetry.api.common.AttributesBuilder; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; -import java.util.Map; -import org.checkerframework.checker.nullness.qual.Nullable; - -final class PeerServiceAttributesServerExtractor - extends PeerServiceAttributesExtractor { - - private final Map peerServiceMapping; - private final NetAttributesServerExtractor netAttributesExtractor; - - PeerServiceAttributesServerExtractor( - Map peerServiceMapping, - NetAttributesServerExtractor netAttributesExtractor) { - this.peerServiceMapping = peerServiceMapping; - this.netAttributesExtractor = netAttributesExtractor; - } - - @Override - protected void onStart(AttributesBuilder attributes, REQUEST request) { - String peerName = netAttributesExtractor.peerName(request); - String peerService = mapToPeerService(peerName); - if (peerService == null) { - String peerIp = netAttributesExtractor.peerIp(request); - peerService = mapToPeerService(peerIp); - } - if (peerService != null) { - attributes.put(SemanticAttributes.PEER_SERVICE, peerService); - } - } - - @Override - protected void onEnd( - AttributesBuilder attributes, - REQUEST request, - @Nullable RESPONSE response, - @Nullable Throwable error) {} - - private String mapToPeerService(String endpoint) { - if (endpoint == null) { - return null; - } - return peerServiceMapping.get(endpoint); - } -} From b3c79087cebfb83f952a3532c755c333167e9d69 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 6 Oct 2021 13:00:05 -0700 Subject: [PATCH 13/26] Fix merge conflict --- .../liberty/dispatcher/LibertyDispatcherSingletons.java | 2 +- .../javaagent/instrumentation/undertow/UndertowSingletons.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java index 8a247d9a35d6..bcdbef0075de 100644 --- a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java +++ b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java @@ -9,6 +9,7 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; +import io.opentelemetry.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesExtractor; @@ -17,7 +18,6 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; public final class LibertyDispatcherSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.liberty-dispatcher"; diff --git a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java index 31dbb0116a33..06b2ab277938 100644 --- a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java +++ b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java @@ -9,6 +9,7 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; +import io.opentelemetry.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesExtractor; @@ -19,7 +20,6 @@ import io.opentelemetry.instrumentation.api.servlet.AppServerBridge; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; import io.opentelemetry.javaagent.bootstrap.undertow.UndertowActiveHandlers; -import io.opentelemetry.javaagent.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import io.undertow.server.HttpServerExchange; public final class UndertowSingletons { From 1a9ebe902c71261ea7e27bf6dff3e6a85c78a4ac Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 6 Oct 2021 13:17:35 -0700 Subject: [PATCH 14/26] rename --- .../opentelemetry/benchmark/InstrumenterBenchmark.java | 4 ++-- .../api/instrumenter/AttributesExtractor.java | 4 ++-- .../instrumenter/PeerServiceAttributesExtractor.java | 8 ++++---- ...InetSocketAddressNetClientAttributesExtractor.java} | 6 +++--- ...InetSocketAddressNetServerAttributesExtractor.java} | 6 +++--- ...xtractor.java => NetClientAttributesExtractor.java} | 4 ++-- ...xtractor.java => NetServerAttributesExtractor.java} | 4 ++-- .../api/instrumenter/InstrumenterTest.java | 6 +++--- .../PeerServiceAttributesClientExtractorTest.java | 4 ++-- .../PeerServiceAttributesServerExtractorTest.java | 4 ++-- ...SocketAddressNetClientAttributesExtractorTest.java} | 6 +++--- ...SocketAddressNetServerAttributesExtractorTest.java} | 6 +++--- ...Test.java => NetClientAttributesExtractorTest.java} | 10 +++++----- ...Test.java => NetServerAttributesExtractorTest.java} | 10 +++++----- .../internal/DubboNetClientAttributesExtractor.java | 4 ++-- .../internal/DubboNetServerAttributesExtractor.java | 4 ++-- .../ApacheHttpAsyncClientNetAttributesExtractor.java | 4 ++-- .../v2_0/ApacheHttpClientNetAttributesExtractor.java | 4 ++-- .../v4_0/ApacheHttpClientNetAttributesExtractor.java | 4 ++-- .../v4_3/ApacheHttpClientNetAttributesExtractor.java | 4 ++-- .../v5_0/ApacheHttpClientNetAttributesExtractor.java | 4 ++-- .../internal/ArmeriaNetClientAttributesExtractor.java | 4 ++-- .../internal/ArmeriaNetServerAttributesExtractor.java | 4 ++-- .../v1_9/AsyncHttpClientNetAttributesExtractor.java | 4 ++-- .../v2_0/AsyncHttpClientNetAttributesExtractor.java | 4 ++-- .../v2_0/AsyncHttpClientSingletons.java | 4 ++-- .../v3_0/CassandraNetAttributesExtractor.java | 4 ++-- .../v4_0/CassandraNetAttributesExtractor.java | 4 ++-- ...lasticsearchRestNetResponseAttributesExtractor.java | 4 ++-- .../Elasticsearch6TransportNetAttributesExtractor.java | 4 ++-- ...ElasticTransportNetResponseAttributesExtractor.java | 4 ++-- .../GoogleHttpClientNetAttributesExtractor.java | 4 ++-- .../internal/GrpcNetClientAttributesExtractor.java | 4 ++-- .../internal/GrpcNetServerAttributesExtractor.java | 4 ++-- .../HttpUrlNetAttributesExtractor.java | 4 ++-- .../httpclient/JdkHttpNetAttributesExtractor.java | 4 ++-- .../v1_1/JaxRsClientNetAttributesExtractor.java | 4 ++-- .../v2_0/JaxRsClientNetAttributesExtractor.java | 4 ++-- .../v2_0/ResteasyClientNetAttributesExtractor.java | 4 ++-- .../jdbc/internal/JdbcNetAttributesExtractor.java | 4 ++-- .../jedis/v1_4/JedisNetAttributesExtractor.java | 4 ++-- .../jedis/v3_0/JedisNetAttributesExtractor.java | 4 ++-- .../JettyHttpClientNetAttributesExtractor.java | 4 ++-- .../KubernetesNetAttributesExtractor.java | 4 ++-- .../v4_0/LettuceConnectNetAttributesExtractor.java | 4 ++-- .../v5_0/LettuceConnectNetAttributesExtractor.java | 4 ++-- .../LibertyDispatcherNetAttributesExtractor.java | 4 ++-- .../dispatcher/LibertyDispatcherSingletons.java | 4 ++-- .../okhttp/v2_2/OkHttp2NetAttributesExtractor.java | 4 ++-- .../instrumentation/okhttp/v2_2/OkHttp2Singletons.java | 4 ++-- .../v3_0/internal/OkHttpNetAttributesExtractor.java | 4 ++-- .../playws/PlayWsClientNetAttributesExtractor.java | 4 ++-- .../internal/RatpackNetAttributesExtractor.java | 4 ++-- .../redisson/RedissonNetAttributesExtractor.java | 4 ++-- .../restlet/v1_0/RestletNetAttributesExtractor.java | 4 ++-- .../restlet/v1_0/RestletTracingBuilder.java | 4 ++-- .../servlet/ServletNetAttributesExtractor.java | 4 ++-- .../spring/web/SpringWebNetAttributesExtractor.java | 4 ++-- .../webmvc/SpringWebMvcNetAttributesExtractor.java | 4 ++-- .../tomcat/common/TomcatInstrumenterBuilder.java | 4 ++-- .../tomcat/common/TomcatNetAttributesExtractor.java | 4 ++-- .../undertow/UndertowNetAttributesExtractor.java | 4 ++-- .../instrumentation/undertow/UndertowSingletons.java | 4 ++-- 63 files changed, 139 insertions(+), 139 deletions(-) rename instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/{InetSocketAddressNetAttributesClientExtractor.java => InetSocketAddressNetClientAttributesExtractor.java} (90%) rename instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/{InetSocketAddressNetAttributesServerExtractor.java => InetSocketAddressNetServerAttributesExtractor.java} (89%) rename instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/{NetAttributesClientExtractor.java => NetClientAttributesExtractor.java} (92%) rename instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/{NetAttributesServerExtractor.java => NetServerAttributesExtractor.java} (92%) rename instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/{InetSocketAddressNetAttributesClientExtractorTest.java => InetSocketAddressNetClientAttributesExtractorTest.java} (94%) rename instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/{InetSocketAddressNetAttributesServerExtractorTest.java => InetSocketAddressNetServerAttributesExtractorTest.java} (94%) rename instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/{NetAttributesClientExtractorTest.java => NetClientAttributesExtractorTest.java} (90%) rename instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/{NetAttributesServerExtractorTest.java => NetServerAttributesExtractorTest.java} (90%) diff --git a/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java b/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java index fbfdb38c2938..633157993bc5 100644 --- a/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java +++ b/benchmark/src/jmh/java/io/opentelemetry/benchmark/InstrumenterBenchmark.java @@ -11,7 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.CapturedHttpHeaders; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import java.util.Collections; @@ -120,7 +120,7 @@ protected List responseHeader(Void unused, Void unused2, String name) { } static class ConstantNetAttributesExtractor - extends InetSocketAddressNetAttributesServerExtractor { + extends InetSocketAddressNetServerAttributesExtractor { private static final InetSocketAddress ADDRESS = InetSocketAddress.createUnresolved("localhost", 8080); diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java index 895099af0aec..2ad655c132d1 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java @@ -9,7 +9,7 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.instrumentation.api.instrumenter.db.DbAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import org.checkerframework.checker.nullness.qual.Nullable; /** @@ -22,7 +22,7 @@ * * @see DbAttributesExtractor * @see HttpClientAttributesExtractor - * @see NetAttributesServerExtractor + * @see NetServerAttributesExtractor */ public abstract class AttributesExtractor { /** 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 0a8240b21cec..27c1513fba3c 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 @@ -7,7 +7,7 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.instrumentation.api.config.Config; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.Map; import org.checkerframework.checker.nullness.qual.Nullable; @@ -27,12 +27,12 @@ public final class PeerServiceAttributesExtractor Config.get().getMap("otel.instrumentation.common.peer-service-mapping"); private final Map peerServiceMapping; - private final NetAttributesClientExtractor netAttributesExtractor; + private final NetClientAttributesExtractor netAttributesExtractor; // visible for tests PeerServiceAttributesExtractor( Map peerServiceMapping, - NetAttributesClientExtractor netAttributesExtractor) { + NetClientAttributesExtractor netAttributesExtractor) { this.peerServiceMapping = peerServiceMapping; this.netAttributesExtractor = netAttributesExtractor; } @@ -42,7 +42,7 @@ public final class PeerServiceAttributesExtractor * netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute. */ public static PeerServiceAttributesExtractor create( - NetAttributesClientExtractor netAttributesExtractor) { + NetClientAttributesExtractor netAttributesExtractor) { return new PeerServiceAttributesExtractor<>( JAVAAGENT_PEER_SERVICE_MAPPING, netAttributesExtractor); } diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesClientExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesExtractor.java similarity index 90% rename from instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesClientExtractor.java rename to instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesExtractor.java index c42dae3e0588..176e9e114015 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesClientExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesExtractor.java @@ -14,10 +14,10 @@ * href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/span-general.md#general-network-connection-attributes">Network * attributes from a {@link InetSocketAddress}. Most network libraries will provide access to a * {@link InetSocketAddress} so this is a convenient alternative to {@link - * NetAttributesClientExtractor}. There is no meaning to implement both in the same instrumentation. + * NetClientAttributesExtractor}. There is no meaning to implement both in the same instrumentation. */ -public abstract class InetSocketAddressNetAttributesClientExtractor - extends NetAttributesClientExtractor { +public abstract class InetSocketAddressNetClientAttributesExtractor + extends NetClientAttributesExtractor { @Nullable public abstract InetSocketAddress getAddress(REQUEST request, @Nullable RESPONSE response); diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesExtractor.java similarity index 89% rename from instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractor.java rename to instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesExtractor.java index 67b1b26907db..d3733b1df615 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesExtractor.java @@ -14,10 +14,10 @@ * href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/span-general.md#general-network-connection-attributes">Network * attributes from a {@link InetSocketAddress}. Most network libraries will provide access to a * {@link InetSocketAddress} so this is a convenient alternative to {@link - * NetAttributesServerExtractor}. There is no meaning to implement both in the same instrumentation. + * NetServerAttributesExtractor}. There is no meaning to implement both in the same instrumentation. */ -public abstract class InetSocketAddressNetAttributesServerExtractor - extends NetAttributesServerExtractor { +public abstract class InetSocketAddressNetServerAttributesExtractor + extends NetServerAttributesExtractor { @Nullable public abstract InetSocketAddress getAddress(REQUEST request); diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractor.java similarity index 92% rename from instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractor.java rename to instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractor.java index ee5a76e1fae9..c3b1373ebbbd 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractor.java @@ -14,9 +14,9 @@ * 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 InetSocketAddressNetAttributesClientExtractor}. + * it is more convenient to use {@link InetSocketAddressNetClientAttributesExtractor}. */ -public abstract class NetAttributesClientExtractor +public abstract class NetClientAttributesExtractor extends AttributesExtractor { @Override diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractor.java similarity index 92% rename from instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractor.java rename to instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractor.java index 2e9873dbc1f0..62d610919a2c 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractor.java @@ -14,9 +14,9 @@ * 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 InetSocketAddressNetAttributesServerExtractor}. + * it is more convenient to use {@link InetSocketAddressNetServerAttributesExtractor}. */ -public abstract class NetAttributesServerExtractor +public abstract class NetServerAttributesExtractor extends AttributesExtractor { @Override diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterTest.java index cfce9cc177b4..f93f579e3edc 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterTest.java @@ -27,7 +27,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.messaging.MessageOperation; import io.opentelemetry.instrumentation.api.instrumenter.messaging.MessagingAttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.rpc.RpcAttributesExtractor; import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; import io.opentelemetry.sdk.testing.junit5.OpenTelemetryExtension; @@ -154,7 +154,7 @@ public String get(Map carrier, String key) { MessagingAttributesExtractor, Map> mockMessagingAttributes; @Mock RpcAttributesExtractor, Map> mockRpcAttributes; - @Mock NetAttributesServerExtractor, Map> mockNetAttributes; + @Mock NetServerAttributesExtractor, Map> mockNetAttributes; @Test void server() { @@ -668,7 +668,7 @@ private static LinkData expectedSpanLink() { } private static final class ConstantNetPeerIpExtractor - extends NetAttributesServerExtractor { + extends NetServerAttributesExtractor { private final String peerIp; diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractorTest.java index 08b08b73837d..e5ed39af2f1d 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractorTest.java @@ -14,7 +14,7 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.HashMap; import java.util.Map; @@ -25,7 +25,7 @@ @ExtendWith(MockitoExtension.class) class PeerServiceAttributesClientExtractorTest { - @Mock NetAttributesClientExtractor netAttributesExtractor; + @Mock NetClientAttributesExtractor netAttributesExtractor; @Test void shouldNotSetAnyValueIfNetExtractorReturnsNulls() { diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractorTest.java index a8b6904370c6..49e314ceb1d5 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractorTest.java @@ -14,7 +14,7 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.HashMap; import java.util.Map; @@ -25,7 +25,7 @@ @ExtendWith(MockitoExtension.class) class PeerServiceAttributesServerExtractorTest { - @Mock NetAttributesServerExtractor netAttributesExtractor; + @Mock NetServerAttributesExtractor netAttributesExtractor; @Test void shouldNotSetAnyValueIfNetExtractorReturnsNulls() { diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesClientExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesExtractorTest.java similarity index 94% rename from instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesClientExtractorTest.java rename to instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesExtractorTest.java index da5b50022b1d..f33a1ae77406 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesClientExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesExtractorTest.java @@ -17,11 +17,11 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class InetSocketAddressNetAttributesClientExtractorTest { +class InetSocketAddressNetClientAttributesExtractorTest { - private final InetSocketAddressNetAttributesClientExtractor + private final InetSocketAddressNetClientAttributesExtractor extractor = - new InetSocketAddressNetAttributesClientExtractor< + new InetSocketAddressNetClientAttributesExtractor< InetSocketAddress, InetSocketAddress>() { @Override public InetSocketAddress getAddress( diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesExtractorTest.java similarity index 94% rename from instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractorTest.java rename to instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesExtractorTest.java index dba40f7243e6..e5600bd4eb2b 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetAttributesServerExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesExtractorTest.java @@ -17,11 +17,11 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class InetSocketAddressNetAttributesServerExtractorTest { +class InetSocketAddressNetServerAttributesExtractorTest { - private final InetSocketAddressNetAttributesServerExtractor + private final InetSocketAddressNetServerAttributesExtractor extractor = - new InetSocketAddressNetAttributesServerExtractor< + new InetSocketAddressNetServerAttributesExtractor< InetSocketAddress, InetSocketAddress>() { @Override public InetSocketAddress getAddress(InetSocketAddress request) { diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractorTest.java similarity index 90% rename from instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractorTest.java rename to instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractorTest.java index cebebd1f787a..ff7a86d45401 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesClientExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractorTest.java @@ -15,10 +15,10 @@ import java.util.Map; import org.junit.jupiter.api.Test; -class NetAttributesClientExtractorTest { +class NetClientAttributesExtractorTest { - static class TestNetAttributesClientExtractor - extends NetAttributesClientExtractor, Map> { + static class TestNetClientAttributesExtractor + extends NetClientAttributesExtractor, Map> { @Override public String transport(Map request, Map response) { @@ -64,7 +64,7 @@ void normal() { response.put("peerPort", "42"); response.put("peerIp", "4.3.2.1"); - TestNetAttributesClientExtractor extractor = new TestNetAttributesClientExtractor(); + TestNetClientAttributesExtractor extractor = new TestNetClientAttributesExtractor(); // when AttributesBuilder startAttributes = Attributes.builder(); @@ -97,7 +97,7 @@ public void doesNotSetDuplicateAttributes() { response.put("peerPort", "42"); response.put("peerIp", "4.3.2.1"); - TestNetAttributesClientExtractor extractor = new TestNetAttributesClientExtractor(); + TestNetClientAttributesExtractor extractor = new TestNetClientAttributesExtractor(); // when AttributesBuilder startAttributes = Attributes.builder(); diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractorTest.java similarity index 90% rename from instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractorTest.java rename to instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractorTest.java index d69abb7bd7ca..f87aacdae79b 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetAttributesServerExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractorTest.java @@ -15,10 +15,10 @@ import java.util.Map; import org.junit.jupiter.api.Test; -class NetAttributesServerExtractorTest { +class NetServerAttributesExtractorTest { - static class TestNetAttributesServerExtractor - extends NetAttributesServerExtractor, Map> { + static class TestNetServerAttributesExtractor + extends NetServerAttributesExtractor, Map> { @Override public String transport(Map request) { @@ -55,7 +55,7 @@ void normal() { response.put("peerPort", "42"); response.put("peerIp", "4.3.2.1"); - TestNetAttributesServerExtractor extractor = new TestNetAttributesServerExtractor(); + TestNetServerAttributesExtractor extractor = new TestNetServerAttributesExtractor(); // when AttributesBuilder startAttributes = Attributes.builder(); @@ -89,7 +89,7 @@ public void doesNotSetDuplicateAttributes() { response.put("peerPort", "42"); response.put("peerIp", "4.3.2.1"); - TestNetAttributesServerExtractor extractor = new TestNetAttributesServerExtractor(); + TestNetServerAttributesExtractor extractor = new TestNetServerAttributesExtractor(); // when AttributesBuilder startAttributes = Attributes.builder(); diff --git a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetClientAttributesExtractor.java b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetClientAttributesExtractor.java index 6b16ca3c45ad..f045e5d666d1 100644 --- a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetClientAttributesExtractor.java +++ b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetClientAttributesExtractor.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.InetSocketAddressNetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; import java.net.InetSocketAddress; import org.apache.dubbo.rpc.Result; import org.checkerframework.checker.nullness.qual.Nullable; public final class DubboNetClientAttributesExtractor - extends InetSocketAddressNetAttributesClientExtractor { + extends InetSocketAddressNetClientAttributesExtractor { @Override public @Nullable InetSocketAddress getAddress(DubboRequest request, @Nullable Result response) { diff --git a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetServerAttributesExtractor.java b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetServerAttributesExtractor.java index 437bd05f4835..53c194733de3 100644 --- a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetServerAttributesExtractor.java +++ b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboNetServerAttributesExtractor.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.InetSocketAddressNetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor; import java.net.InetSocketAddress; import org.apache.dubbo.rpc.Result; import org.checkerframework.checker.nullness.qual.Nullable; public final class DubboNetServerAttributesExtractor - extends InetSocketAddressNetAttributesServerExtractor { + extends InetSocketAddressNetServerAttributesExtractor { @Override public @Nullable InetSocketAddress getAddress(DubboRequest request) { 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/ApacheHttpAsyncClientNetAttributesExtractor.java index 35d7b753ef37..30ac42a7220d 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/ApacheHttpAsyncClientNetAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpasyncclient; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.http.HttpResponse; import org.checkerframework.checker.nullness.qual.Nullable; final class ApacheHttpAsyncClientNetAttributesExtractor - extends NetAttributesClientExtractor { + extends NetClientAttributesExtractor { @Override public String transport(ApacheHttpClientRequest request, @Nullable HttpResponse response) { 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/ApacheHttpClientNetAttributesExtractor.java index 2cdf1853d2e9..798930eeaac8 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/ApacheHttpClientNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.commons.httpclient.HostConfiguration; import org.apache.commons.httpclient.HttpMethod; import org.checkerframework.checker.nullness.qual.Nullable; final class ApacheHttpClientNetAttributesExtractor - extends NetAttributesClientExtractor { + extends NetClientAttributesExtractor { @Override public String transport(HttpMethod request, @Nullable HttpMethod response) { 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/ApacheHttpClientNetAttributesExtractor.java index 8d5cc19698be..1621c8f203ba 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/ApacheHttpClientNetAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v4_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.http.HttpResponse; import org.checkerframework.checker.nullness.qual.Nullable; final class ApacheHttpClientNetAttributesExtractor - extends NetAttributesClientExtractor { + extends NetClientAttributesExtractor { @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/ApacheHttpClientNetAttributesExtractor.java b/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientNetAttributesExtractor.java index 3a3e17a63630..80aac6144d3c 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/ApacheHttpClientNetAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.instrumentation.apachehttpclient.v4_3; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.http.HttpResponse; import org.checkerframework.checker.nullness.qual.Nullable; final class ApacheHttpClientNetAttributesExtractor - extends NetAttributesClientExtractor { + extends NetClientAttributesExtractor { @Override public String transport(ApacheHttpClientRequest 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/ApacheHttpClientNetAttributesExtractor.java b/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientNetAttributesExtractor.java index 6171711e8172..0def37bf300d 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/ApacheHttpClientNetAttributesExtractor.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v5_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.HttpResponse; @@ -14,7 +14,7 @@ import org.slf4j.LoggerFactory; final class ApacheHttpClientNetAttributesExtractor - extends NetAttributesClientExtractor { + extends NetClientAttributesExtractor { private static final Logger logger = LoggerFactory.getLogger(ApacheHttpClientNetAttributesExtractor.class); diff --git a/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetClientAttributesExtractor.java b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetClientAttributesExtractor.java index 5c8c7a392af9..b8068547e6ff 100644 --- a/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetClientAttributesExtractor.java +++ b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetClientAttributesExtractor.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.InetSocketAddressNetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import java.net.SocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; public final class ArmeriaNetClientAttributesExtractor - extends InetSocketAddressNetAttributesClientExtractor { + extends InetSocketAddressNetClientAttributesExtractor { @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/internal/ArmeriaNetServerAttributesExtractor.java b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetServerAttributesExtractor.java index 93c68fdeb701..91d1dc9acfb9 100644 --- a/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetServerAttributesExtractor.java +++ b/instrumentation/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaNetServerAttributesExtractor.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.InetSocketAddressNetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import java.net.SocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; public final class ArmeriaNetServerAttributesExtractor - extends InetSocketAddressNetAttributesServerExtractor { + extends InetSocketAddressNetServerAttributesExtractor { @Override public String transport(RequestContext ctx) { 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/AsyncHttpClientNetAttributesExtractor.java index 914910f342b0..a55d55329df6 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/AsyncHttpClientNetAttributesExtractor.java @@ -7,12 +7,12 @@ import com.ning.http.client.Request; import com.ning.http.client.Response; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; final class AsyncHttpClientNetAttributesExtractor - extends NetAttributesClientExtractor { + extends NetClientAttributesExtractor { @Override public String transport(Request 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/AsyncHttpClientNetAttributesExtractor.java b/instrumentation/async-http-client/async-http-client-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v2_0/AsyncHttpClientNetAttributesExtractor.java index c654b8e9ecf5..2112422c20c5 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/AsyncHttpClientNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.asynchttpclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import org.asynchttpclient.Response; import org.checkerframework.checker.nullness.qual.Nullable; final class AsyncHttpClientNetAttributesExtractor - extends InetSocketAddressNetAttributesClientExtractor { + extends InetSocketAddressNetClientAttributesExtractor { @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 2543ecec5d2b..03f4b19adcfe 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 @@ -14,7 +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.NetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import org.asynchttpclient.Response; public final class AsyncHttpClientSingletons { @@ -29,7 +29,7 @@ public final class AsyncHttpClientSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetAttributesClientExtractor netAttributesExtractor = + NetClientAttributesExtractor netAttributesExtractor = new AsyncHttpClientNetAttributesExtractor(); INSTRUMENTER = 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/CassandraNetAttributesExtractor.java index 8bde531e4387..d3b3d22a0ec9 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/CassandraNetAttributesExtractor.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.InetSocketAddressNetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; final class CassandraNetAttributesExtractor - extends InetSocketAddressNetAttributesClientExtractor { + extends InetSocketAddressNetClientAttributesExtractor { @Override @Nullable 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/CassandraNetAttributesExtractor.java index d4a65e785dae..89accdb0c179 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/CassandraNetAttributesExtractor.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.InetSocketAddressNetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; import java.net.InetSocketAddress; import java.net.SocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; final class CassandraNetAttributesExtractor - extends InetSocketAddressNetAttributesClientExtractor { + extends InetSocketAddressNetClientAttributesExtractor { @Override @Nullable 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/ElasticsearchRestNetResponseAttributesExtractor.java index deb2b9a06308..1ec6330c184a 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/ElasticsearchRestNetResponseAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.rest; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; import org.elasticsearch.client.Response; final class ElasticsearchRestNetResponseAttributesExtractor - extends NetAttributesClientExtractor { + extends NetClientAttributesExtractor { @Override public String transport(String operation, Response response) { return SemanticAttributes.NetTransportValues.IP_TCP; 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/Elasticsearch6TransportNetAttributesExtractor.java index 5e8601ee2820..393d2ff4e963 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/Elasticsearch6TransportNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.v6_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportRequest; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; import org.elasticsearch.action.ActionResponse; public class Elasticsearch6TransportNetAttributesExtractor - extends InetSocketAddressNetAttributesClientExtractor { + extends InetSocketAddressNetClientAttributesExtractor { @Override public @Nullable String transport( ElasticTransportRequest request, @Nullable ActionResponse response) { 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/ElasticTransportNetResponseAttributesExtractor.java index a2efc0642795..b06f8def120d 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/ElasticTransportNetResponseAttributesExtractor.java @@ -5,12 +5,12 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import org.checkerframework.checker.nullness.qual.Nullable; import org.elasticsearch.action.ActionResponse; public class ElasticTransportNetResponseAttributesExtractor - extends NetAttributesClientExtractor { + extends NetClientAttributesExtractor { @Override public @Nullable 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/GoogleHttpClientNetAttributesExtractor.java index 8c0ac56bff7e..6bf848c05ca4 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/GoogleHttpClientNetAttributesExtractor.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.NetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; final class GoogleHttpClientNetAttributesExtractor - extends NetAttributesClientExtractor { + extends NetClientAttributesExtractor { @Override public String transport(HttpRequest request, @Nullable HttpResponse response) { 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/GrpcNetClientAttributesExtractor.java index e7d7034b4bc5..687d47823dfd 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/GrpcNetClientAttributesExtractor.java @@ -6,7 +6,7 @@ package io.opentelemetry.instrumentation.grpc.v1_6.internal; import io.grpc.Status; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; import io.opentelemetry.instrumentation.grpc.v1_6.GrpcRequest; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; @@ -14,7 +14,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; public final class GrpcNetClientAttributesExtractor - extends InetSocketAddressNetAttributesClientExtractor { + extends InetSocketAddressNetClientAttributesExtractor { @Override @Nullable public InetSocketAddress getAddress(GrpcRequest request, @Nullable Status response) { diff --git a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetServerAttributesExtractor.java b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetServerAttributesExtractor.java index 777693e0201c..46e4530003fe 100644 --- a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetServerAttributesExtractor.java +++ b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcNetServerAttributesExtractor.java @@ -6,7 +6,7 @@ package io.opentelemetry.instrumentation.grpc.v1_6.internal; import io.grpc.Status; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor; import io.opentelemetry.instrumentation.grpc.v1_6.GrpcRequest; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; @@ -14,7 +14,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; public final class GrpcNetServerAttributesExtractor - extends InetSocketAddressNetAttributesServerExtractor { + extends InetSocketAddressNetServerAttributesExtractor { @Override @Nullable public InetSocketAddress getAddress(GrpcRequest request) { 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/HttpUrlNetAttributesExtractor.java index b557414b8e91..4db163268098 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/HttpUrlNetAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.httpurlconnection; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.HttpURLConnection; import org.checkerframework.checker.nullness.qual.Nullable; class HttpUrlNetAttributesExtractor - extends NetAttributesClientExtractor { + extends NetClientAttributesExtractor { @Override public @Nullable String transport(HttpURLConnection connection, @Nullable Integer status) { return SemanticAttributes.NetTransportValues.IP_TCP; 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/JdkHttpNetAttributesExtractor.java index cfbd9d20313b..a9851db9a048 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/JdkHttpNetAttributesExtractor.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.httpclient; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.http.HttpRequest; import java.net.http.HttpResponse; @@ -14,7 +14,7 @@ import org.slf4j.LoggerFactory; public class JdkHttpNetAttributesExtractor - extends NetAttributesServerExtractor> { + extends NetServerAttributesExtractor> { private static final Logger logger = LoggerFactory.getLogger(JdkHttpNetAttributesExtractor.class); 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/JaxRsClientNetAttributesExtractor.java index 9c22719e736d..f06b882123be 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/JaxRsClientNetAttributesExtractor.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.NetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; final class JaxRsClientNetAttributesExtractor - extends NetAttributesClientExtractor { + extends NetClientAttributesExtractor { @Override public String transport(ClientRequest request, @Nullable ClientResponse 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/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/JaxRsClientNetAttributesExtractor.java index 2c4ec0713501..08d7e9b65573 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/JaxRsClientNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.jaxrsclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.ws.rs.client.ClientRequestContext; import javax.ws.rs.client.ClientResponseContext; import org.checkerframework.checker.nullness.qual.Nullable; final class JaxRsClientNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetServerAttributesExtractor { @Override public String transport(ClientRequestContext request) { 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/ResteasyClientNetAttributesExtractor.java index d7c355f991f9..55e06bb626f8 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/ResteasyClientNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.jaxrsclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.ws.rs.core.Response; import org.checkerframework.checker.nullness.qual.Nullable; import org.jboss.resteasy.client.jaxrs.internal.ClientInvocation; final class ResteasyClientNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetServerAttributesExtractor { @Override public String transport(ClientInvocation request) { 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/JdbcNetAttributesExtractor.java index fde76e11a439..caacc3904544 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/JdbcNetAttributesExtractor.java @@ -5,11 +5,11 @@ package io.opentelemetry.instrumentation.jdbc.internal; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import org.checkerframework.checker.nullness.qual.Nullable; public final class JdbcNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetServerAttributesExtractor { @Nullable @Override 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/JedisNetAttributesExtractor.java index 40800d8d3210..378bd7c08c88 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/JedisNetAttributesExtractor.java @@ -5,10 +5,10 @@ package io.opentelemetry.javaagent.instrumentation.jedis.v1_4; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import org.checkerframework.checker.nullness.qual.Nullable; -final class JedisNetAttributesExtractor extends NetAttributesClientExtractor { +final class JedisNetAttributesExtractor extends NetClientAttributesExtractor { @Override @Nullable 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/JedisNetAttributesExtractor.java index ca0c6acf95bc..64b9a7b3a575 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/JedisNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.jedis.v3_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import java.net.Socket; import org.checkerframework.checker.nullness.qual.Nullable; final class JedisNetAttributesExtractor - extends InetSocketAddressNetAttributesClientExtractor { + extends InetSocketAddressNetClientAttributesExtractor { @Override public @Nullable InetSocketAddress getAddress(JedisRequest jedisRequest, @Nullable Void unused) { 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/JettyHttpClientNetAttributesExtractor.java index ab9d345485ce..dc414cf7a3da 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/JettyHttpClientNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.api.Response; public class JettyHttpClientNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetServerAttributesExtractor { @Override public String transport(Request request) { 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/KubernetesNetAttributesExtractor.java index a1d6d0da77d1..c0111140fb9c 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/KubernetesNetAttributesExtractor.java @@ -6,13 +6,13 @@ package io.opentelemetry.javaagent.instrumentation.kubernetesclient; import io.kubernetes.client.openapi.ApiResponse; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import okhttp3.Request; import org.checkerframework.checker.nullness.qual.Nullable; class KubernetesNetAttributesExtractor - extends NetAttributesServerExtractor> { + extends NetServerAttributesExtractor> { @Override public String transport(Request request) { 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/LettuceConnectNetAttributesExtractor.java index 72b51591c97e..2c10240af760 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/LettuceConnectNetAttributesExtractor.java @@ -6,11 +6,11 @@ package io.opentelemetry.javaagent.instrumentation.lettuce.v4_0; import com.lambdaworks.redis.RedisURI; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import org.checkerframework.checker.nullness.qual.Nullable; final class LettuceConnectNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetServerAttributesExtractor { @Override @Nullable 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/LettuceConnectNetAttributesExtractor.java index 140788943b47..cbb63312ba50 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/LettuceConnectNetAttributesExtractor.java @@ -6,11 +6,11 @@ package io.opentelemetry.javaagent.instrumentation.lettuce.v5_0; import io.lettuce.core.RedisURI; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import org.checkerframework.checker.nullness.qual.Nullable; final class LettuceConnectNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetServerAttributesExtractor { @Override @Nullable diff --git a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesExtractor.java b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesExtractor.java index 4ff1068ecdc6..8ea1a1cfc7ef 100644 --- a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesExtractor.java +++ b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesExtractor.java @@ -5,12 +5,12 @@ package io.opentelemetry.javaagent.instrumentation.liberty.dispatcher; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; public class LibertyDispatcherNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetServerAttributesExtractor { @Override public String transport(LibertyRequest libertyRequest) { diff --git a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java index bcdbef0075de..d958e59d5474 100644 --- a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java +++ b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java @@ -16,7 +16,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.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; public final class LibertyDispatcherSingletons { @@ -31,7 +31,7 @@ public final class LibertyDispatcherSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetAttributesServerExtractor netAttributesExtractor = + NetServerAttributesExtractor netAttributesExtractor = new LibertyDispatcherNetAttributesExtractor(); INSTRUMENTER = 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/OkHttp2NetAttributesExtractor.java index 59fbdc45dc58..cb0810baac48 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/OkHttp2NetAttributesExtractor.java @@ -7,12 +7,12 @@ import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; public final class OkHttp2NetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetServerAttributesExtractor { @Override public String transport(Request request) { 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 c10aec3b337a..215126ead0e7 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 @@ -20,7 +20,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.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; public final class OkHttp2Singletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.okhttp-2.2"; @@ -35,7 +35,7 @@ public final class OkHttp2Singletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetAttributesServerExtractor netAttributesExtractor = + NetServerAttributesExtractor netAttributesExtractor = new OkHttp2NetAttributesExtractor(); OpenTelemetry openTelemetry = GlobalOpenTelemetry.get(); 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/OkHttpNetAttributesExtractor.java index 9ba1781181b5..7b151c223271 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/OkHttpNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.instrumentation.okhttp.v3_0.internal; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import okhttp3.Request; import okhttp3.Response; import org.checkerframework.checker.nullness.qual.Nullable; public final class OkHttpNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetServerAttributesExtractor { @Override public String transport(Request request) { 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/PlayWsClientNetAttributesExtractor.java index d6fd701d480e..832da2e0897d 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/PlayWsClientNetAttributesExtractor.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.playws; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; @@ -13,7 +13,7 @@ import play.shaded.ahc.org.asynchttpclient.Response; final class PlayWsClientNetAttributesExtractor - extends InetSocketAddressNetAttributesClientExtractor { + extends InetSocketAddressNetClientAttributesExtractor { @Override public String transport(Request request, @Nullable Response response) { diff --git a/instrumentation/ratpack-1.4/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesExtractor.java b/instrumentation/ratpack-1.4/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesExtractor.java index 8fe080d886db..542af94905c3 100644 --- a/instrumentation/ratpack-1.4/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesExtractor.java +++ b/instrumentation/ratpack-1.4/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.instrumentation.ratpack.internal; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; import ratpack.http.Request; import ratpack.http.Response; public final class RatpackNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetServerAttributesExtractor { @Override @Nullable public String transport(Request request) { 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/RedissonNetAttributesExtractor.java index 925c29c1240d..5e13851b4b7b 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/RedissonNetAttributesExtractor.java @@ -5,12 +5,12 @@ package io.opentelemetry.javaagent.instrumentation.redisson; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesClientExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesExtractor; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; final class RedissonNetAttributesExtractor - extends InetSocketAddressNetAttributesClientExtractor { + extends InetSocketAddressNetClientAttributesExtractor { @Override public InetSocketAddress getAddress(RedissonRequest request, @Nullable Void unused) { diff --git a/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesExtractor.java b/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesExtractor.java index 5d4922acf606..eecc64cdfd2b 100644 --- a/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesExtractor.java +++ b/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.instrumentation.restlet.v1_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; import org.restlet.data.Request; import org.restlet.data.Response; -final class RestletNetAttributesExtractor extends NetAttributesServerExtractor { +final class RestletNetAttributesExtractor extends NetServerAttributesExtractor { @Override public String transport(Request request) { return SemanticAttributes.NetTransportValues.IP_TCP; diff --git a/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletTracingBuilder.java b/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletTracingBuilder.java index 7e8a10180b1c..26b3a171f1b5 100644 --- a/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletTracingBuilder.java +++ b/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletTracingBuilder.java @@ -14,7 +14,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.CapturedHttpHeaders; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import java.util.ArrayList; import java.util.List; import org.restlet.data.Request; @@ -66,7 +66,7 @@ public RestletTracing build() { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetAttributesServerExtractor netAttributesExtractor = + NetServerAttributesExtractor netAttributesExtractor = new RestletNetAttributesExtractor(); Instrumenter instrumenter = diff --git a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesExtractor.java b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesExtractor.java index dd8e7d313f83..ad40d42efdc9 100644 --- a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesExtractor.java +++ b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesExtractor.java @@ -5,12 +5,12 @@ package io.opentelemetry.javaagent.instrumentation.servlet; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import io.opentelemetry.instrumentation.servlet.ServletAccessor; import org.checkerframework.checker.nullness.qual.Nullable; public class ServletNetAttributesExtractor - extends NetAttributesServerExtractor< + extends NetServerAttributesExtractor< ServletRequestContext, ServletResponseContext> { private final ServletAccessor accessor; diff --git a/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesExtractor.java b/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesExtractor.java index 5a401baf43d8..7226c714355e 100644 --- a/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesExtractor.java +++ b/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.instrumentation.spring.web; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; import org.springframework.http.HttpRequest; import org.springframework.http.client.ClientHttpResponse; final class SpringWebNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetServerAttributesExtractor { @Override public String transport(HttpRequest httpRequest) { return SemanticAttributes.NetTransportValues.IP_TCP; diff --git a/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesExtractor.java b/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesExtractor.java index e3b89a32d2e7..561482b5992d 100644 --- a/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesExtractor.java +++ b/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.instrumentation.spring.webmvc; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.checkerframework.checker.nullness.qual.Nullable; final class SpringWebMvcNetAttributesExtractor - extends NetAttributesServerExtractor { + extends NetServerAttributesExtractor { @Override public String transport(HttpServletRequest request) { return SemanticAttributes.NetTransportValues.IP_TCP; diff --git a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java index 2b136fb2b318..0bafae8a68f2 100644 --- a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java +++ b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java @@ -17,7 +17,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.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import io.opentelemetry.instrumentation.api.servlet.AppServerBridge; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; import io.opentelemetry.instrumentation.servlet.ServletAccessor; @@ -39,7 +39,7 @@ public static Instrumenter newInstrumente HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetAttributesServerExtractor netAttributesExtractor = + NetServerAttributesExtractor netAttributesExtractor = new TomcatNetAttributesExtractor(); AttributesExtractor additionalAttributeExtractor = new TomcatAdditionalAttributesExtractor<>(accessor, servletEntityProvider); diff --git a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesExtractor.java b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesExtractor.java index 02bdb86aaae6..366ea499083b 100644 --- a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesExtractor.java +++ b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesExtractor.java @@ -5,13 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.tomcat.common; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import org.apache.coyote.ActionCode; import org.apache.coyote.Request; import org.apache.coyote.Response; import org.checkerframework.checker.nullness.qual.Nullable; -public class TomcatNetAttributesExtractor extends NetAttributesServerExtractor { +public class TomcatNetAttributesExtractor extends NetServerAttributesExtractor { @Override public @Nullable String transport(Request request) { diff --git a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowNetAttributesExtractor.java b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowNetAttributesExtractor.java index 17d14fcafb32..ac278775732e 100644 --- a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowNetAttributesExtractor.java +++ b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowNetAttributesExtractor.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.undertow; -import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import io.undertow.server.HttpServerExchange; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; public class UndertowNetAttributesExtractor - extends InetSocketAddressNetAttributesServerExtractor { + extends InetSocketAddressNetServerAttributesExtractor { @Override public @Nullable InetSocketAddress getAddress(HttpServerExchange exchange) { diff --git a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java index 06b2ab277938..870e2d91c87f 100644 --- a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java +++ b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java @@ -16,7 +16,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.NetAttributesServerExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; import io.opentelemetry.instrumentation.api.servlet.AppServerBridge; import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming; import io.opentelemetry.javaagent.bootstrap.undertow.UndertowActiveHandlers; @@ -34,7 +34,7 @@ public final class UndertowSingletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetAttributesServerExtractor netAttributesExtractor = + NetServerAttributesExtractor netAttributesExtractor = new UndertowNetAttributesExtractor(); INSTRUMENTER = From 298f306f1595f97202c6062755c46a434c15d131 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 6 Oct 2021 13:11:21 -0700 Subject: [PATCH 15/26] Armeria --- .../api/instrumenter/AttributesExtractor.java | 5 +++ .../ConstantAttributesExtractor.java | 34 +++++++++++++++++++ .../armeria/v1_3/ArmeriaSingletons.java | 14 +------- .../armeria/v1_3/ArmeriaTracingBuilder.java | 21 +++++++++++- 4 files changed, 60 insertions(+), 14 deletions(-) create mode 100644 instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/ConstantAttributesExtractor.java diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java index 2ad655c132d1..458aa2fc5b46 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java @@ -51,4 +51,9 @@ protected static void set( attributes.put(key, value); } } + + public static AttributesExtractor constant( + AttributeKey attributeKey, T attributeValue) { + return new ConstantAttributesExtractor<>(attributeKey, attributeValue); + } } diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/ConstantAttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/ConstantAttributesExtractor.java new file mode 100644 index 000000000000..cf438866c966 --- /dev/null +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/ConstantAttributesExtractor.java @@ -0,0 +1,34 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.api.instrumenter; + +import io.opentelemetry.api.common.AttributeKey; +import io.opentelemetry.api.common.AttributesBuilder; +import org.checkerframework.checker.nullness.qual.Nullable; + +final class ConstantAttributesExtractor + extends AttributesExtractor { + + private final AttributeKey attributeKey; + private final T attributeValue; + + ConstantAttributesExtractor(AttributeKey attributeKey, T attributeValue) { + this.attributeKey = attributeKey; + this.attributeValue = attributeValue; + } + + @Override + protected void onStart(AttributesBuilder attributes, REQUEST request) { + attributes.put(attributeKey, attributeValue); + } + + @Override + protected void onEnd( + AttributesBuilder attributes, + REQUEST request, + @Nullable RESPONSE response, + @Nullable Throwable error) {} +} diff --git a/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java b/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java index 0ae5cb1266a4..0c59e1fd0056 100644 --- a/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java +++ b/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java @@ -6,13 +6,9 @@ package io.opentelemetry.javaagent.instrumentation.armeria.v1_3; import com.linecorp.armeria.client.HttpClient; -import com.linecorp.armeria.common.RequestContext; -import com.linecorp.armeria.common.logging.RequestLog; import com.linecorp.armeria.server.HttpService; import io.opentelemetry.api.GlobalOpenTelemetry; -import io.opentelemetry.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import io.opentelemetry.instrumentation.armeria.v1_3.ArmeriaTracing; -import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaNetClientAttributesExtractor; import java.util.function.Function; // Holds singleton references to decorators to match against during suppression. @@ -23,15 +19,7 @@ public final class ArmeriaSingletons { public static final Function SERVER_DECORATOR; static { - // TODO (trask) split ArmeriaNetAttributesExtractor into client/server - // (and move into ArmeriaTracingBuilder?) - PeerServiceAttributesExtractor peerServiceAttributesExtractor = - PeerServiceAttributesExtractor.create(new ArmeriaNetClientAttributesExtractor()); - - ArmeriaTracing tracing = - ArmeriaTracing.newBuilder(GlobalOpenTelemetry.get()) - .addAttributeExtractor(peerServiceAttributesExtractor) - .build(); + ArmeriaTracing tracing = ArmeriaTracing.newBuilder(GlobalOpenTelemetry.get()).build(); CLIENT_DECORATOR = tracing.newClientDecorator(); SERVER_DECORATOR = tracing.newServiceDecorator(); 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 b252ac76557e..689f2edfe2b9 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 @@ -14,6 +14,7 @@ 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.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.CapturedHttpHeaders; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; @@ -22,16 +23,19 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaNetClientAttributesExtractor; import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaNetServerAttributesExtractor; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.ArrayList; import java.util.List; import java.util.function.Function; import java.util.stream.Stream; +import org.checkerframework.checker.nullness.qual.Nullable; public final class ArmeriaTracingBuilder { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.armeria-1.3"; private final OpenTelemetry openTelemetry; + @Nullable private String peerService; private CapturedHttpHeaders capturedHttpClientHeaders = CapturedHttpHeaders.client(Config.get()); private CapturedHttpHeaders capturedHttpServerHeaders = CapturedHttpHeaders.server(Config.get()); @@ -66,6 +70,10 @@ public ArmeriaTracingBuilder addAttributeExtractor( return this; } + public void setPeerService(String peerService) { + this.peerService = peerService; + } + /** * Configure the HTTP client instrumentation to capture chosen HTTP request and response headers * as span attributes. @@ -112,11 +120,22 @@ public ArmeriaTracing build() { Stream.of(clientInstrumenterBuilder, serverInstrumenterBuilder) .forEach(instrumenter -> instrumenter.addAttributesExtractors(additionalExtractors)); + ArmeriaNetClientAttributesExtractor netAttributesClientExtractor = + new ArmeriaNetClientAttributesExtractor(); + + if (peerService != null) { + clientInstrumenterBuilder.addAttributesExtractor( + AttributesExtractor.constant(SemanticAttributes.PEER_SERVICE, peerService)); + } else { + clientInstrumenterBuilder.addAttributesExtractor( + PeerServiceAttributesExtractor.create(netAttributesClientExtractor)); + } + clientInstrumenterBuilder .setSpanStatusExtractor( statusExtractorTransformer.apply( HttpSpanStatusExtractor.create(clientAttributesExtractor))) - .addAttributesExtractor(new ArmeriaNetClientAttributesExtractor()) + .addAttributesExtractor(netAttributesClientExtractor) .addAttributesExtractor(clientAttributesExtractor) .addRequestMetrics(HttpClientMetrics.get()); serverInstrumenterBuilder From f14aed6bd4c95c471b3c4319e1d3ba1fac0b6921 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 6 Oct 2021 13:22:21 -0700 Subject: [PATCH 16/26] peer.service is only for clients --- .../api/instrumenter/PeerServiceAttributesExtractor.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 27c1513fba3c..32838207c887 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 @@ -48,9 +48,7 @@ public static PeerServiceAttributesExtractor Date: Wed, 6 Oct 2021 13:23:39 -0700 Subject: [PATCH 17/26] rename --- .../instrumenter/PeerServiceAttributesExtractor.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 32838207c887..3059762af343 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 @@ -27,14 +27,14 @@ public final class PeerServiceAttributesExtractor Config.get().getMap("otel.instrumentation.common.peer-service-mapping"); private final Map peerServiceMapping; - private final NetClientAttributesExtractor netAttributesExtractor; + private final NetClientAttributesExtractor netClientAttributesExtractor; // visible for tests PeerServiceAttributesExtractor( Map peerServiceMapping, - NetClientAttributesExtractor netAttributesExtractor) { + NetClientAttributesExtractor netClientAttributesExtractor) { this.peerServiceMapping = peerServiceMapping; - this.netAttributesExtractor = netAttributesExtractor; + this.netClientAttributesExtractor = netClientAttributesExtractor; } /** @@ -56,10 +56,10 @@ protected void onEnd( REQUEST request, @Nullable RESPONSE response, @Nullable Throwable error) { - String peerName = netAttributesExtractor.peerName(request, response); + String peerName = netClientAttributesExtractor.peerName(request, response); String peerService = mapToPeerService(peerName); if (peerService == null) { - String peerIp = netAttributesExtractor.peerIp(request, response); + String peerIp = netClientAttributesExtractor.peerIp(request, response); peerService = mapToPeerService(peerIp); } if (peerService != null) { From 1eb9a42a81b6cfdfccd4510d8be8cbda542c084c Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 6 Oct 2021 13:39:04 -0700 Subject: [PATCH 18/26] WIP --- .../apachedubbo/v2_7/DubboTracingBuilder.java | 7 +++++++ .../armeria/v1_3/ArmeriaTracingBuilder.java | 1 + 2 files changed, 8 insertions(+) diff --git a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java index 3d59bd783b15..8657a97e68e0 100644 --- a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java +++ b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java @@ -16,6 +16,7 @@ import java.util.ArrayList; import java.util.List; import org.apache.dubbo.rpc.Result; +import org.checkerframework.checker.nullness.qual.Nullable; /** A builder of {@link DubboTracing}. */ public final class DubboTracingBuilder { @@ -23,6 +24,7 @@ public final class DubboTracingBuilder { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.apache-dubbo-2.7"; private final OpenTelemetry openTelemetry; + @Nullable private String peerService; private final List> attributesExtractors = new ArrayList<>(); @@ -30,6 +32,11 @@ public final class DubboTracingBuilder { this.openTelemetry = openTelemetry; } + /** Sets the {@code peer.service} attribute for http client spans. */ + public void setPeerService(String peerService) { + this.peerService = peerService; + } + /** * Adds an additional {@link AttributesExtractor} to invoke to set attributes to instrumented * items. 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 689f2edfe2b9..04e4c6184bd0 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 @@ -70,6 +70,7 @@ public ArmeriaTracingBuilder addAttributeExtractor( return this; } + /** Sets the {@code peer.service} attribute for http client spans. */ public void setPeerService(String peerService) { this.peerService = peerService; } From fa71463322ed0d51f46a9348d4ea2487fbbced79 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 6 Oct 2021 13:43:26 -0700 Subject: [PATCH 19/26] Sync Dubbo with Armeria --- .../apachedubbo/v2_7/DubboTracing.java | 10 +++---- .../apachedubbo/v2_7/DubboTracingBuilder.java | 26 ++++++++++++------- .../apachedubbo/v2_7/TracingFilter.java | 8 +++--- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracing.java b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracing.java index bf6edcdace14..85c1cabbf3f0 100644 --- a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracing.java +++ b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracing.java @@ -23,18 +23,18 @@ public static DubboTracingBuilder newBuilder(OpenTelemetry openTelemetry) { return new DubboTracingBuilder(openTelemetry); } - private final Instrumenter serverInstrumenter; private final Instrumenter clientInstrumenter; + private final Instrumenter serverInstrumenter; DubboTracing( - Instrumenter serverInstrumenter, - Instrumenter clientInstrumenter) { - this.serverInstrumenter = serverInstrumenter; + Instrumenter clientInstrumenter, + Instrumenter serverInstrumenter) { this.clientInstrumenter = clientInstrumenter; + this.serverInstrumenter = serverInstrumenter; } /** Returns a new Dubbo {@link Filter} that traces Dubbo RPC invocations. */ public Filter newFilter() { - return new TracingFilter(serverInstrumenter, clientInstrumenter); + return new TracingFilter(clientInstrumenter, serverInstrumenter); } } diff --git a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java index 8657a97e68e0..f17acb6a04cd 100644 --- a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java +++ b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java @@ -15,6 +15,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.rpc.RpcSpanNameExtractor; import java.util.ArrayList; import java.util.List; +import java.util.stream.Stream; import org.apache.dubbo.rpc.Result; import org.checkerframework.checker.nullness.qual.Nullable; @@ -53,18 +54,25 @@ public DubboTracing build() { SpanNameExtractor spanNameExtractor = RpcSpanNameExtractor.create(rpcAttributesExtractor); - InstrumenterBuilder builder = + InstrumenterBuilder clientInstrumenterBuilder = Instrumenter.newBuilder( openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor) - .addAttributesExtractor(rpcAttributesExtractor) - .addAttributesExtractors(attributesExtractors); + .addAttributesExtractor(new DubboNetClientAttributesExtractor()); + InstrumenterBuilder serverInstrumenterBuilder = + Instrumenter.newBuilder( + openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor) + .addAttributesExtractor(new DubboNetServerAttributesExtractor()); + + Stream.of(clientInstrumenterBuilder, serverInstrumenterBuilder) + .forEach( + instrumenter -> { + instrumenter + .addAttributesExtractors(rpcAttributesExtractor) + .addAttributesExtractors(attributesExtractors); + }); return new DubboTracing( - builder - .addAttributesExtractor(new DubboNetServerAttributesExtractor()) - .newServerInstrumenter(new DubboHeadersGetter()), - builder - .addAttributesExtractor(new DubboNetClientAttributesExtractor()) - .newClientInstrumenter(new DubboHeadersSetter())); + clientInstrumenterBuilder.newClientInstrumenter(new DubboHeadersSetter()), + clientInstrumenterBuilder.newServerInstrumenter(new DubboHeadersGetter())); } } diff --git a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/TracingFilter.java b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/TracingFilter.java index 1dc7f6f1e5c8..1607985369f9 100644 --- a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/TracingFilter.java +++ b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/TracingFilter.java @@ -18,14 +18,14 @@ final class TracingFilter implements Filter { - private final Instrumenter serverInstrumenter; private final Instrumenter clientInstrumenter; + private final Instrumenter serverInstrumenter; TracingFilter( - Instrumenter serverInstrumenter, - Instrumenter clientInstrumenter) { - this.serverInstrumenter = serverInstrumenter; + Instrumenter clientInstrumenter, + Instrumenter serverInstrumenter) { this.clientInstrumenter = clientInstrumenter; + this.serverInstrumenter = serverInstrumenter; } @Override From 2a2118880e30f9a08f3c8dccb4ddeab4fefd9506 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 6 Oct 2021 13:51:21 -0700 Subject: [PATCH 20/26] More Dubbo and Armeria --- .../apachedubbo/v2_7/OpenTelemetryFilter.java | 10 +----- .../apachedubbo/v2_7/DubboTracingBuilder.java | 33 ++++++++++++------- .../armeria/v1_3/ArmeriaSingletons.java | 2 +- .../armeria/v1_3/ArmeriaTracingBuilder.java | 28 ++++++++-------- 4 files changed, 38 insertions(+), 35 deletions(-) diff --git a/instrumentation/apache-dubbo-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachedubbo/v2_7/OpenTelemetryFilter.java b/instrumentation/apache-dubbo-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachedubbo/v2_7/OpenTelemetryFilter.java index 6d46360518a3..b14b6e574d83 100644 --- a/instrumentation/apache-dubbo-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachedubbo/v2_7/OpenTelemetryFilter.java +++ b/instrumentation/apache-dubbo-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachedubbo/v2_7/OpenTelemetryFilter.java @@ -7,8 +7,6 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.apachedubbo.v2_7.DubboTracing; -import io.opentelemetry.instrumentation.apachedubbo.v2_7.internal.DubboNetServerAttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import org.apache.dubbo.common.extension.Activate; import org.apache.dubbo.rpc.Filter; import org.apache.dubbo.rpc.Invocation; @@ -21,13 +19,7 @@ public class OpenTelemetryFilter implements Filter { private final Filter delegate; public OpenTelemetryFilter() { - DubboNetServerAttributesExtractor netAttributesExtractor = - new DubboNetServerAttributesExtractor(); - delegate = - DubboTracing.newBuilder(GlobalOpenTelemetry.get()) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) - .build() - .newFilter(); + delegate = DubboTracing.create(GlobalOpenTelemetry.get()).newFilter(); } @Override diff --git a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java index f17acb6a04cd..04fa2ac02812 100644 --- a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java +++ b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java @@ -11,8 +11,10 @@ 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.rpc.RpcSpanNameExtractor; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; @@ -54,22 +56,31 @@ public DubboTracing build() { SpanNameExtractor spanNameExtractor = RpcSpanNameExtractor.create(rpcAttributesExtractor); + DubboNetClientAttributesExtractor netClientAttributesExtractor = + new DubboNetClientAttributesExtractor(); + InstrumenterBuilder clientInstrumenterBuilder = - Instrumenter.newBuilder( - openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor) - .addAttributesExtractor(new DubboNetClientAttributesExtractor()); + Instrumenter.newBuilder(openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor); InstrumenterBuilder serverInstrumenterBuilder = - Instrumenter.newBuilder( - openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor) - .addAttributesExtractor(new DubboNetServerAttributesExtractor()); + Instrumenter.newBuilder(openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor); Stream.of(clientInstrumenterBuilder, serverInstrumenterBuilder) .forEach( - instrumenter -> { - instrumenter - .addAttributesExtractors(rpcAttributesExtractor) - .addAttributesExtractors(attributesExtractors); - }); + instrumenter -> + instrumenter + .addAttributesExtractors(rpcAttributesExtractor) + .addAttributesExtractors(attributesExtractors)); + + clientInstrumenterBuilder.addAttributesExtractor(netClientAttributesExtractor); + serverInstrumenterBuilder.addAttributesExtractor(new DubboNetServerAttributesExtractor()); + + if (peerService != null) { + clientInstrumenterBuilder.addAttributesExtractor( + AttributesExtractor.constant(SemanticAttributes.PEER_SERVICE, peerService)); + } else { + clientInstrumenterBuilder.addAttributesExtractor( + PeerServiceAttributesExtractor.create(netClientAttributesExtractor)); + } return new DubboTracing( clientInstrumenterBuilder.newClientInstrumenter(new DubboHeadersSetter()), diff --git a/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java b/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java index 0c59e1fd0056..76caf37d9439 100644 --- a/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java +++ b/instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java @@ -19,7 +19,7 @@ public final class ArmeriaSingletons { public static final Function SERVER_DECORATOR; static { - ArmeriaTracing tracing = ArmeriaTracing.newBuilder(GlobalOpenTelemetry.get()).build(); + ArmeriaTracing tracing = ArmeriaTracing.create(GlobalOpenTelemetry.get()); CLIENT_DECORATOR = tracing.newClientDecorator(); SERVER_DECORATOR = tracing.newServiceDecorator(); 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 04e4c6184bd0..75827bc6fe7e 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 @@ -102,7 +102,7 @@ public ArmeriaTracingBuilder captureHttpServerHeaders( } public ArmeriaTracing build() { - ArmeriaHttpClientAttributesExtractor clientAttributesExtractor = + ArmeriaHttpClientAttributesExtractor httpClientAttributesExtractor = new ArmeriaHttpClientAttributesExtractor(capturedHttpClientHeaders); ArmeriaHttpServerAttributesExtractor serverAttributesExtractor = new ArmeriaHttpServerAttributesExtractor(capturedHttpServerHeaders); @@ -111,7 +111,7 @@ public ArmeriaTracing build() { Instrumenter.newBuilder( openTelemetry, INSTRUMENTATION_NAME, - HttpSpanNameExtractor.create(clientAttributesExtractor)); + HttpSpanNameExtractor.create(httpClientAttributesExtractor)); InstrumenterBuilder serverInstrumenterBuilder = Instrumenter.newBuilder( openTelemetry, @@ -121,23 +121,15 @@ public ArmeriaTracing build() { Stream.of(clientInstrumenterBuilder, serverInstrumenterBuilder) .forEach(instrumenter -> instrumenter.addAttributesExtractors(additionalExtractors)); - ArmeriaNetClientAttributesExtractor netAttributesClientExtractor = + ArmeriaNetClientAttributesExtractor netClientAttributesExtractor = new ArmeriaNetClientAttributesExtractor(); - if (peerService != null) { - clientInstrumenterBuilder.addAttributesExtractor( - AttributesExtractor.constant(SemanticAttributes.PEER_SERVICE, peerService)); - } else { - clientInstrumenterBuilder.addAttributesExtractor( - PeerServiceAttributesExtractor.create(netAttributesClientExtractor)); - } - clientInstrumenterBuilder .setSpanStatusExtractor( statusExtractorTransformer.apply( - HttpSpanStatusExtractor.create(clientAttributesExtractor))) - .addAttributesExtractor(netAttributesClientExtractor) - .addAttributesExtractor(clientAttributesExtractor) + HttpSpanStatusExtractor.create(httpClientAttributesExtractor))) + .addAttributesExtractor(netClientAttributesExtractor) + .addAttributesExtractor(httpClientAttributesExtractor) .addRequestMetrics(HttpClientMetrics.get()); serverInstrumenterBuilder .setSpanStatusExtractor( @@ -147,6 +139,14 @@ public ArmeriaTracing build() { .addAttributesExtractor(serverAttributesExtractor) .addRequestMetrics(HttpServerMetrics.get()); + if (peerService != null) { + clientInstrumenterBuilder.addAttributesExtractor( + AttributesExtractor.constant(SemanticAttributes.PEER_SERVICE, peerService)); + } else { + clientInstrumenterBuilder.addAttributesExtractor( + PeerServiceAttributesExtractor.create(netClientAttributesExtractor)); + } + return new ArmeriaTracing( clientInstrumenterBuilder.newClientInstrumenter(new ClientRequestContextSetter()), serverInstrumenterBuilder.newServerInstrumenter(new RequestContextGetter())); From 22aa4ec956b13cbc96885520645fb81adc26d506 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 6 Oct 2021 15:10:03 -0700 Subject: [PATCH 21/26] gRPC --- .../grpc/v1_6/GrpcSingletons.java | 7 --- .../grpc/v1_6/GrpcTracingBuilder.java | 50 +++++++++++++++---- 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/instrumentation/grpc-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grpc/v1_6/GrpcSingletons.java b/instrumentation/grpc-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grpc/v1_6/GrpcSingletons.java index a2d73d11ce1b..6b0e78c411a4 100644 --- a/instrumentation/grpc-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grpc/v1_6/GrpcSingletons.java +++ b/instrumentation/grpc-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grpc/v1_6/GrpcSingletons.java @@ -8,14 +8,10 @@ import io.grpc.ClientInterceptor; import io.grpc.Context; import io.grpc.ServerInterceptor; -import io.grpc.Status; import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.api.config.Config; -import io.opentelemetry.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; -import io.opentelemetry.instrumentation.grpc.v1_6.GrpcRequest; import io.opentelemetry.instrumentation.grpc.v1_6.GrpcTracing; import io.opentelemetry.instrumentation.grpc.v1_6.internal.ContextStorageBridge; -import io.opentelemetry.instrumentation.grpc.v1_6.internal.GrpcNetServerAttributesExtractor; // Holds singleton references. public final class GrpcSingletons { @@ -29,13 +25,10 @@ public final class GrpcSingletons { static { boolean experimentalSpanAttributes = Config.get().getBoolean("otel.instrumentation.grpc.experimental-span-attributes", false); - PeerServiceAttributesExtractor peerServiceAttributesExtractor = - PeerServiceAttributesExtractor.create(new GrpcNetServerAttributesExtractor()); GrpcTracing tracing = GrpcTracing.newBuilder(GlobalOpenTelemetry.get()) .setCaptureExperimentalSpanAttributes(experimentalSpanAttributes) - .addAttributeExtractor(peerServiceAttributesExtractor) .build(); CLIENT_INTERCEPTOR = tracing.newClientInterceptor(); 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 08818edb1f63..9aff5327884d 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 @@ -10,11 +10,15 @@ 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.SpanKindExtractor; import io.opentelemetry.instrumentation.grpc.v1_6.internal.GrpcNetClientAttributesExtractor; import io.opentelemetry.instrumentation.grpc.v1_6.internal.GrpcNetServerAttributesExtractor; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.ArrayList; import java.util.List; +import java.util.stream.Stream; +import org.checkerframework.checker.nullness.qual.Nullable; /** A builder of {@link GrpcTracing}. */ public final class GrpcTracingBuilder { @@ -22,6 +26,7 @@ public final class GrpcTracingBuilder { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.grpc-1.6"; private final OpenTelemetry openTelemetry; + @Nullable private String peerService; private final List> additionalExtractors = new ArrayList<>(); @@ -42,6 +47,11 @@ public GrpcTracingBuilder addAttributeExtractor( return this; } + /** Sets the {@code peer.service} attribute for http client spans. */ + public void setPeerService(String peerService) { + this.peerService = peerService; + } + /** * Sets whether experimental attributes should be set to spans. These attributes may be changed or * removed in the future, so only enable this if you know you do not require attributes filled by @@ -55,21 +65,39 @@ public GrpcTracingBuilder setCaptureExperimentalSpanAttributes( /** Returns a new {@link GrpcTracing} with the settings of this {@link GrpcTracingBuilder}. */ public GrpcTracing build() { - InstrumenterBuilder instrumenterBuilder = + InstrumenterBuilder clientInstrumenterBuilder = Instrumenter.newBuilder(openTelemetry, INSTRUMENTATION_NAME, new GrpcSpanNameExtractor()); - instrumenterBuilder - .setSpanStatusExtractor(new GrpcSpanStatusExtractor()) - .addAttributesExtractors(new GrpcRpcAttributesExtractor(), new GrpcAttributesExtractor()) - .addAttributesExtractors(additionalExtractors); + InstrumenterBuilder serverInstrumenterBuilder = + Instrumenter.newBuilder(openTelemetry, INSTRUMENTATION_NAME, new GrpcSpanNameExtractor()); + + Stream.of(clientInstrumenterBuilder, serverInstrumenterBuilder) + .forEach( + instrumenter -> + instrumenter + .setSpanStatusExtractor(new GrpcSpanStatusExtractor()) + .addAttributesExtractors( + new GrpcRpcAttributesExtractor(), new GrpcAttributesExtractor()) + .addAttributesExtractors(additionalExtractors)); + + GrpcNetClientAttributesExtractor netClientAttributesExtractor = + new GrpcNetClientAttributesExtractor(); + + clientInstrumenterBuilder.addAttributesExtractor(netClientAttributesExtractor); + serverInstrumenterBuilder.addAttributesExtractor(new GrpcNetServerAttributesExtractor()); + + if (peerService != null) { + clientInstrumenterBuilder.addAttributesExtractor( + AttributesExtractor.constant(SemanticAttributes.PEER_SERVICE, peerService)); + } else { + clientInstrumenterBuilder.addAttributesExtractor( + PeerServiceAttributesExtractor.create(netClientAttributesExtractor)); + } + return new GrpcTracing( - instrumenterBuilder - .addAttributesExtractor(new GrpcNetServerAttributesExtractor()) - .newServerInstrumenter(GrpcExtractAdapter.GETTER), + serverInstrumenterBuilder.newServerInstrumenter(GrpcExtractAdapter.GETTER), // gRPC client interceptors require two phases, one to set up request and one to execute. // So we go ahead and inject manually in this instrumentation. - instrumenterBuilder - .addAttributesExtractor(new GrpcNetClientAttributesExtractor()) - .newInstrumenter(SpanKindExtractor.alwaysClient()), + clientInstrumenterBuilder.newInstrumenter(SpanKindExtractor.alwaysClient()), openTelemetry.getPropagators(), captureExperimentalSpanAttributes); } From a544c09028e6746ae4b14e35a7b226bc6588d31b Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 6 Oct 2021 15:13:56 -0700 Subject: [PATCH 22/26] Revert some Dubbo changes --- .../apachedubbo/v2_7/DubboTracing.java | 10 +++++----- .../apachedubbo/v2_7/DubboTracingBuilder.java | 12 ++++++------ .../apachedubbo/v2_7/TracingFilter.java | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracing.java b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracing.java index 85c1cabbf3f0..bf6edcdace14 100644 --- a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracing.java +++ b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracing.java @@ -23,18 +23,18 @@ public static DubboTracingBuilder newBuilder(OpenTelemetry openTelemetry) { return new DubboTracingBuilder(openTelemetry); } - private final Instrumenter clientInstrumenter; private final Instrumenter serverInstrumenter; + private final Instrumenter clientInstrumenter; DubboTracing( - Instrumenter clientInstrumenter, - Instrumenter serverInstrumenter) { - this.clientInstrumenter = clientInstrumenter; + Instrumenter serverInstrumenter, + Instrumenter clientInstrumenter) { this.serverInstrumenter = serverInstrumenter; + this.clientInstrumenter = clientInstrumenter; } /** Returns a new Dubbo {@link Filter} that traces Dubbo RPC invocations. */ public Filter newFilter() { - return new TracingFilter(clientInstrumenter, serverInstrumenter); + return new TracingFilter(serverInstrumenter, clientInstrumenter); } } diff --git a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java index 04fa2ac02812..f67799bbd983 100644 --- a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java +++ b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java @@ -59,20 +59,20 @@ public DubboTracing build() { DubboNetClientAttributesExtractor netClientAttributesExtractor = new DubboNetClientAttributesExtractor(); - InstrumenterBuilder clientInstrumenterBuilder = - Instrumenter.newBuilder(openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor); InstrumenterBuilder serverInstrumenterBuilder = Instrumenter.newBuilder(openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor); + InstrumenterBuilder clientInstrumenterBuilder = + Instrumenter.newBuilder(openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor); - Stream.of(clientInstrumenterBuilder, serverInstrumenterBuilder) + Stream.of(serverInstrumenterBuilder, clientInstrumenterBuilder) .forEach( instrumenter -> instrumenter .addAttributesExtractors(rpcAttributesExtractor) .addAttributesExtractors(attributesExtractors)); - clientInstrumenterBuilder.addAttributesExtractor(netClientAttributesExtractor); serverInstrumenterBuilder.addAttributesExtractor(new DubboNetServerAttributesExtractor()); + clientInstrumenterBuilder.addAttributesExtractor(netClientAttributesExtractor); if (peerService != null) { clientInstrumenterBuilder.addAttributesExtractor( @@ -83,7 +83,7 @@ public DubboTracing build() { } return new DubboTracing( - clientInstrumenterBuilder.newClientInstrumenter(new DubboHeadersSetter()), - clientInstrumenterBuilder.newServerInstrumenter(new DubboHeadersGetter())); + clientInstrumenterBuilder.newServerInstrumenter(new DubboHeadersGetter()), + clientInstrumenterBuilder.newClientInstrumenter(new DubboHeadersSetter())); } } diff --git a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/TracingFilter.java b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/TracingFilter.java index 1607985369f9..1dc7f6f1e5c8 100644 --- a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/TracingFilter.java +++ b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/TracingFilter.java @@ -18,14 +18,14 @@ final class TracingFilter implements Filter { - private final Instrumenter clientInstrumenter; private final Instrumenter serverInstrumenter; + private final Instrumenter clientInstrumenter; TracingFilter( - Instrumenter clientInstrumenter, - Instrumenter serverInstrumenter) { - this.clientInstrumenter = clientInstrumenter; + Instrumenter serverInstrumenter, + Instrumenter clientInstrumenter) { this.serverInstrumenter = serverInstrumenter; + this.clientInstrumenter = clientInstrumenter; } @Override From 6ce28e3a3fa17f315bc537414c2c6aaa850d89ea Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 6 Oct 2021 15:33:27 -0700 Subject: [PATCH 23/26] more peer.service --- .../httpclient/JdkHttpNetAttributesExtractor.java | 12 ++++++------ .../v2_0/JaxRsClientNetAttributesExtractor.java | 14 ++++++++------ .../v2_0/ResteasyClientNetAttributesExtractor.java | 12 ++++++------ .../jdbc/internal/JdbcNetAttributesExtractor.java | 12 ++++++------ .../JettyHttpClientNetAttributesExtractor.java | 12 ++++++------ .../KubernetesNetAttributesExtractor.java | 12 ++++++------ .../v4_0/LettuceConnectNetAttributesExtractor.java | 12 ++++++------ .../v5_0/LettuceConnectNetAttributesExtractor.java | 12 ++++++------ .../dispatcher/LibertyDispatcherSingletons.java | 2 -- .../okhttp/v2_2/OkHttp2NetAttributesExtractor.java | 12 ++++++------ .../okhttp/v2_2/OkHttp2Singletons.java | 4 ++-- .../internal/OkHttpNetAttributesExtractor.java | 12 ++++++------ .../servlet/ServletInstrumenterBuilder.java | 2 -- .../tomcat/common/TomcatInstrumenterBuilder.java | 2 -- .../undertow/UndertowSingletons.java | 2 -- 15 files changed, 64 insertions(+), 70 deletions(-) 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/JdkHttpNetAttributesExtractor.java index a9851db9a048..f3de1a2f9b34 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/JdkHttpNetAttributesExtractor.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.httpclient; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.http.HttpRequest; import java.net.http.HttpResponse; @@ -14,22 +14,22 @@ import org.slf4j.LoggerFactory; public class JdkHttpNetAttributesExtractor - extends NetServerAttributesExtractor> { + extends NetClientAttributesExtractor> { private static final Logger logger = LoggerFactory.getLogger(JdkHttpNetAttributesExtractor.class); @Override - public String transport(HttpRequest httpRequest) { + public String transport(HttpRequest httpRequest, @Nullable HttpResponse response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public @Nullable String peerName(HttpRequest httpRequest) { + public @Nullable String peerName(HttpRequest httpRequest, @Nullable HttpResponse response) { return httpRequest.uri().getHost(); } @Override - public @Nullable Integer peerPort(HttpRequest httpRequest) { + public @Nullable Integer peerPort(HttpRequest httpRequest, @Nullable HttpResponse response) { int port = httpRequest.uri().getPort(); if (port != -1) { return port; @@ -50,7 +50,7 @@ public String transport(HttpRequest httpRequest) { } @Override - public @Nullable String peerIp(HttpRequest httpRequest) { + public @Nullable String peerIp(HttpRequest httpRequest, @Nullable HttpResponse response) { return null; } } 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/JaxRsClientNetAttributesExtractor.java index 08d7e9b65573..46d70a4b8076 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/JaxRsClientNetAttributesExtractor.java @@ -5,27 +5,28 @@ package io.opentelemetry.javaagent.instrumentation.jaxrsclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.ws.rs.client.ClientRequestContext; import javax.ws.rs.client.ClientResponseContext; import org.checkerframework.checker.nullness.qual.Nullable; final class JaxRsClientNetAttributesExtractor - extends NetServerAttributesExtractor { + extends NetClientAttributesExtractor { @Override - public String transport(ClientRequestContext request) { + public String transport(ClientRequestContext request, @Nullable ClientResponseContext response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public @Nullable String peerName(ClientRequestContext request) { + public @Nullable String peerName( + ClientRequestContext request, @Nullable ClientResponseContext response) { return request.getUri().getHost(); } @Override - public Integer peerPort(ClientRequestContext request) { + public Integer peerPort(ClientRequestContext request, @Nullable ClientResponseContext response) { int port = request.getUri().getPort(); if (port != -1) { return port; @@ -34,7 +35,8 @@ public Integer peerPort(ClientRequestContext request) { } @Override - public @Nullable String peerIp(ClientRequestContext request) { + public @Nullable String peerIp( + ClientRequestContext request, @Nullable ClientResponseContext response) { return null; } } 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/ResteasyClientNetAttributesExtractor.java index 55e06bb626f8..3531a1de7504 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/ResteasyClientNetAttributesExtractor.java @@ -5,27 +5,27 @@ package io.opentelemetry.javaagent.instrumentation.jaxrsclient.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import javax.ws.rs.core.Response; import org.checkerframework.checker.nullness.qual.Nullable; import org.jboss.resteasy.client.jaxrs.internal.ClientInvocation; final class ResteasyClientNetAttributesExtractor - extends NetServerAttributesExtractor { + extends NetClientAttributesExtractor { @Override - public String transport(ClientInvocation request) { + public String transport(ClientInvocation request, @Nullable Response response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public @Nullable String peerName(ClientInvocation request) { + public @Nullable String peerName(ClientInvocation request, @Nullable Response response) { return request.getUri().getHost(); } @Override - public Integer peerPort(ClientInvocation request) { + public Integer peerPort(ClientInvocation request, @Nullable Response response) { int port = request.getUri().getPort(); if (port != -1) { return port; @@ -34,7 +34,7 @@ public Integer peerPort(ClientInvocation request) { } @Override - public @Nullable String peerIp(ClientInvocation request) { + public @Nullable String peerIp(ClientInvocation request, @Nullable Response response) { return null; } } 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/JdbcNetAttributesExtractor.java index caacc3904544..1fa982490273 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/JdbcNetAttributesExtractor.java @@ -5,33 +5,33 @@ package io.opentelemetry.instrumentation.jdbc.internal; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import org.checkerframework.checker.nullness.qual.Nullable; public final class JdbcNetAttributesExtractor - extends NetServerAttributesExtractor { + extends NetClientAttributesExtractor { @Nullable @Override - public String transport(DbRequest request) { + public String transport(DbRequest request, @Nullable Void unused) { return null; } @Nullable @Override - public String peerName(DbRequest request) { + public String peerName(DbRequest request, @Nullable Void unused) { return request.getDbInfo().getHost(); } @Nullable @Override - public Integer peerPort(DbRequest request) { + public Integer peerPort(DbRequest request, @Nullable Void unused) { return request.getDbInfo().getPort(); } @Nullable @Override - public String peerIp(DbRequest request) { + public String peerIp(DbRequest request, @Nullable Void unused) { return null; } } 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/JettyHttpClientNetAttributesExtractor.java index dc414cf7a3da..111c6ea11edb 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/JettyHttpClientNetAttributesExtractor.java @@ -5,35 +5,35 @@ package io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.api.Response; public class JettyHttpClientNetAttributesExtractor - extends NetServerAttributesExtractor { + extends NetClientAttributesExtractor { @Override - public String transport(Request request) { + public String transport(Request request, @Nullable Response response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override @Nullable - public String peerName(Request request) { + public String peerName(Request request, @Nullable Response response) { return request.getHost(); } @Override @Nullable - public Integer peerPort(Request request) { + public Integer peerPort(Request request, @Nullable Response response) { return request.getPort(); } @Override @Nullable - public String peerIp(Request request) { + public String peerIp(Request request, @Nullable Response response) { // Return null unless the library supports resolution to something similar to SocketAddress // https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/3012/files#r633188645 return null; 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/KubernetesNetAttributesExtractor.java index c0111140fb9c..f0419bd4e910 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/KubernetesNetAttributesExtractor.java @@ -6,30 +6,30 @@ package io.opentelemetry.javaagent.instrumentation.kubernetesclient; import io.kubernetes.client.openapi.ApiResponse; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import okhttp3.Request; import org.checkerframework.checker.nullness.qual.Nullable; class KubernetesNetAttributesExtractor - extends NetServerAttributesExtractor> { + extends NetClientAttributesExtractor> { @Override - public String transport(Request request) { + public String transport(Request request, @Nullable ApiResponse response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public String peerName(Request request) { + public String peerName(Request request, @Nullable ApiResponse response) { return request.url().host(); } @Override - public Integer peerPort(Request request) { + public Integer peerPort(Request request, @Nullable ApiResponse response) { return request.url().port(); } @Override - public @Nullable String peerIp(Request request) { + public @Nullable String peerIp(Request request, @Nullable ApiResponse response) { return null; } } 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/LettuceConnectNetAttributesExtractor.java index 2c10240af760..f43c0c56007a 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/LettuceConnectNetAttributesExtractor.java @@ -6,31 +6,31 @@ package io.opentelemetry.javaagent.instrumentation.lettuce.v4_0; import com.lambdaworks.redis.RedisURI; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import org.checkerframework.checker.nullness.qual.Nullable; final class LettuceConnectNetAttributesExtractor - extends NetServerAttributesExtractor { + extends NetClientAttributesExtractor { @Override @Nullable - public String transport(RedisURI redisUri) { + public String transport(RedisURI redisUri, @Nullable Void unused) { return null; } @Override - public String peerName(RedisURI redisUri) { + public String peerName(RedisURI redisUri, @Nullable Void unused) { return redisUri.getHost(); } @Override - public Integer peerPort(RedisURI redisUri) { + public Integer peerPort(RedisURI redisUri, @Nullable Void unused) { return redisUri.getPort(); } @Override @Nullable - public String peerIp(RedisURI redisUri) { + public String peerIp(RedisURI redisUri, @Nullable Void unused) { return null; } } 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/LettuceConnectNetAttributesExtractor.java index cbb63312ba50..3293311da4b0 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/LettuceConnectNetAttributesExtractor.java @@ -6,31 +6,31 @@ package io.opentelemetry.javaagent.instrumentation.lettuce.v5_0; import io.lettuce.core.RedisURI; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import org.checkerframework.checker.nullness.qual.Nullable; final class LettuceConnectNetAttributesExtractor - extends NetServerAttributesExtractor { + extends NetClientAttributesExtractor { @Override @Nullable - public String transport(RedisURI redisUri) { + public String transport(RedisURI redisUri, @Nullable Void unused) { return null; } @Override - public String peerName(RedisURI redisUri) { + public String peerName(RedisURI redisUri, @Nullable Void unused) { return redisUri.getHost(); } @Override - public Integer peerPort(RedisURI redisUri) { + public Integer peerPort(RedisURI redisUri, @Nullable Void unused) { return redisUri.getPort(); } @Override @Nullable - public String peerIp(RedisURI redisUri) { + public String peerIp(RedisURI redisUri, @Nullable Void unused) { return null; } } diff --git a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java index d958e59d5474..0256958dfeca 100644 --- a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java +++ b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java @@ -9,7 +9,6 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesExtractor; @@ -40,7 +39,6 @@ public final class LibertyDispatcherSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addContextCustomizer( (context, request, attributes) -> ServerSpanNaming.init(context, CONTAINER)) .addRequestMetrics(HttpServerMetrics.get()) 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/OkHttp2NetAttributesExtractor.java index cb0810baac48..ef86b564307b 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/OkHttp2NetAttributesExtractor.java @@ -7,29 +7,29 @@ import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.checkerframework.checker.nullness.qual.Nullable; public final class OkHttp2NetAttributesExtractor - extends NetServerAttributesExtractor { + extends NetClientAttributesExtractor { @Override - public String transport(Request request) { + public String transport(Request request, @Nullable Response response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public @Nullable String peerName(Request request) { + public @Nullable String peerName(Request request, @Nullable Response response) { return request.url().getHost(); } @Override - public Integer peerPort(Request request) { + public Integer peerPort(Request request, @Nullable Response response) { return request.url().getPort(); } @Override - public @Nullable String peerIp(Request request) { + public @Nullable String peerIp(Request request, @Nullable Response response) { return null; } } 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 215126ead0e7..b0a73b6fa1d3 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 @@ -20,7 +20,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.NetServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; public final class OkHttp2Singletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.okhttp-2.2"; @@ -35,7 +35,7 @@ public final class OkHttp2Singletons { HttpSpanNameExtractor.create(httpAttributesExtractor); SpanStatusExtractor spanStatusExtractor = HttpSpanStatusExtractor.create(httpAttributesExtractor); - NetServerAttributesExtractor netAttributesExtractor = + NetClientAttributesExtractor netAttributesExtractor = new OkHttp2NetAttributesExtractor(); OpenTelemetry openTelemetry = GlobalOpenTelemetry.get(); 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/OkHttpNetAttributesExtractor.java index 7b151c223271..e0d7273895cb 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/OkHttpNetAttributesExtractor.java @@ -5,31 +5,31 @@ package io.opentelemetry.instrumentation.okhttp.v3_0.internal; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import okhttp3.Request; import okhttp3.Response; import org.checkerframework.checker.nullness.qual.Nullable; public final class OkHttpNetAttributesExtractor - extends NetServerAttributesExtractor { + extends NetClientAttributesExtractor { @Override - public String transport(Request request) { + public String transport(Request request, @Nullable Response response) { return SemanticAttributes.NetTransportValues.IP_TCP; } @Override - public @Nullable String peerName(Request request) { + public @Nullable String peerName(Request request, @Nullable Response response) { return request.url().host(); } @Override - public Integer peerPort(Request request) { + public Integer peerPort(Request request, @Nullable Response response) { return request.url().port(); } @Override - public @Nullable String peerIp(Request request) { + public @Nullable String peerIp(Request request, @Nullable Response response) { return null; } } diff --git a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java index d51cb3e0e04a..986223b05ebb 100644 --- a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java +++ b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java @@ -10,7 +10,6 @@ import io.opentelemetry.instrumentation.api.instrumenter.ContextCustomizer; 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.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesExtractor; @@ -73,7 +72,6 @@ public Instrumenter, ServletResponseContext> contextCustomizer : diff --git a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java index 0bafae8a68f2..17d49a875fe2 100644 --- a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java +++ b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterBuilder.java @@ -10,7 +10,6 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesExtractor; @@ -50,7 +49,6 @@ public static Instrumenter newInstrumente .setErrorCauseExtractor(new ServletErrorCauseExtractor<>(accessor)) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addAttributesExtractor(additionalAttributeExtractor) .addContextCustomizer( (context, request, attributes) -> { diff --git a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java index 870e2d91c87f..d928f18f42b6 100644 --- a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java +++ b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java @@ -9,7 +9,6 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesExtractor; @@ -43,7 +42,6 @@ public final class UndertowSingletons { .setSpanStatusExtractor(spanStatusExtractor) .addAttributesExtractor(httpAttributesExtractor) .addAttributesExtractor(netAttributesExtractor) - .addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesExtractor)) .addContextCustomizer( (context, request, attributes) -> { context = ServerSpanNaming.init(context, CONTAINER); From 4801a746cd8c41300c17bba7ccaa1c521d6cc758 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 6 Oct 2021 21:29:27 -0700 Subject: [PATCH 24/26] Fix test --- ...> PeerServiceAttributesExtractorTest.java} | 22 +-- ...rServiceAttributesServerExtractorTest.java | 137 ------------------ 2 files changed, 11 insertions(+), 148 deletions(-) rename instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/{PeerServiceAttributesClientExtractorTest.java => PeerServiceAttributesExtractorTest.java} (83%) delete mode 100644 instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractorTest.java diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractorTest.java similarity index 83% rename from instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractorTest.java rename to instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractorTest.java index e5ed39af2f1d..04a238451432 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesClientExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractorTest.java @@ -24,7 +24,7 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class PeerServiceAttributesClientExtractorTest { +class PeerServiceAttributesExtractorTest { @Mock NetClientAttributesExtractor netAttributesExtractor; @Test @@ -32,8 +32,8 @@ void shouldNotSetAnyValueIfNetExtractorReturnsNulls() { // given Map peerServiceMapping = singletonMap("1.2.3.4", "myService"); - PeerServiceAttributesClientExtractor underTest = - new PeerServiceAttributesClientExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesExtractor underTest = + new PeerServiceAttributesExtractor<>(peerServiceMapping, netAttributesExtractor); // when AttributesBuilder attributes = Attributes.builder(); @@ -49,8 +49,8 @@ void shouldNotSetAnyValueIfPeerNameDoesNotMatch() { // given Map peerServiceMapping = singletonMap("example.com", "myService"); - PeerServiceAttributesClientExtractor underTest = - new PeerServiceAttributesClientExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesExtractor underTest = + new PeerServiceAttributesExtractor<>(peerServiceMapping, netAttributesExtractor); given(netAttributesExtractor.peerName(any(), any())).willReturn("example2.com"); @@ -70,8 +70,8 @@ void shouldNotSetAnyValueIfPeerIpDoesNotMatch() { // given Map peerServiceMapping = singletonMap("1.2.3.4", "myService"); - PeerServiceAttributesClientExtractor underTest = - new PeerServiceAttributesClientExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesExtractor underTest = + new PeerServiceAttributesExtractor<>(peerServiceMapping, netAttributesExtractor); given(netAttributesExtractor.peerIp(any(), any())).willReturn("1.2.3.5"); @@ -93,8 +93,8 @@ void shouldSetPeerNameIfItMatches() { peerServiceMapping.put("example.com", "myService"); peerServiceMapping.put("1.2.3.4", "someOtherService"); - PeerServiceAttributesClientExtractor underTest = - new PeerServiceAttributesClientExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesExtractor underTest = + new PeerServiceAttributesExtractor<>(peerServiceMapping, netAttributesExtractor); given(netAttributesExtractor.peerName(any(), any())).willReturn("example.com"); @@ -117,8 +117,8 @@ void shouldSetPeerIpIfItMatchesAndNameDoesNot() { peerServiceMapping.put("example.com", "myService"); peerServiceMapping.put("1.2.3.4", "someOtherService"); - PeerServiceAttributesClientExtractor underTest = - new PeerServiceAttributesClientExtractor<>(peerServiceMapping, netAttributesExtractor); + PeerServiceAttributesExtractor underTest = + new PeerServiceAttributesExtractor<>(peerServiceMapping, netAttributesExtractor); given(netAttributesExtractor.peerName(any(), any())).willReturn("test.com"); given(netAttributesExtractor.peerIp(any(), any())).willReturn("1.2.3.4"); diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractorTest.java deleted file mode 100644 index 49e314ceb1d5..000000000000 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesServerExtractorTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.instrumentation.api.instrumenter; - -import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; -import static java.util.Collections.singletonMap; -import static org.assertj.core.api.Assertions.entry; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; - -import io.opentelemetry.api.common.Attributes; -import io.opentelemetry.api.common.AttributesBuilder; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor; -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -class PeerServiceAttributesServerExtractorTest { - @Mock NetServerAttributesExtractor netAttributesExtractor; - - @Test - void shouldNotSetAnyValueIfNetExtractorReturnsNulls() { - // given - Map peerServiceMapping = singletonMap("1.2.3.4", "myService"); - - PeerServiceAttributesServerExtractor underTest = - new PeerServiceAttributesServerExtractor<>(peerServiceMapping, netAttributesExtractor); - - // when - AttributesBuilder attributes = Attributes.builder(); - underTest.onStart(attributes, "request"); - underTest.onEnd(attributes, "request", "response", null); - - // then - assertTrue(attributes.build().isEmpty()); - } - - @Test - void shouldNotSetAnyValueIfPeerNameDoesNotMatch() { - // given - Map peerServiceMapping = singletonMap("example.com", "myService"); - - PeerServiceAttributesServerExtractor underTest = - new PeerServiceAttributesServerExtractor<>(peerServiceMapping, netAttributesExtractor); - - given(netAttributesExtractor.peerName(any())).willReturn("example2.com"); - - // when - AttributesBuilder startAttributes = Attributes.builder(); - underTest.onStart(startAttributes, "request"); - AttributesBuilder endAttributes = Attributes.builder(); - underTest.onEnd(endAttributes, "request", "response", null); - - // then - assertTrue(startAttributes.build().isEmpty()); - assertTrue(endAttributes.build().isEmpty()); - } - - @Test - void shouldNotSetAnyValueIfPeerIpDoesNotMatch() { - // given - Map peerServiceMapping = singletonMap("1.2.3.4", "myService"); - - PeerServiceAttributesServerExtractor underTest = - new PeerServiceAttributesServerExtractor<>(peerServiceMapping, netAttributesExtractor); - - given(netAttributesExtractor.peerIp(any())).willReturn("1.2.3.5"); - - // when - AttributesBuilder startAttributes = Attributes.builder(); - underTest.onStart(startAttributes, "request"); - AttributesBuilder endAttributes = Attributes.builder(); - underTest.onEnd(endAttributes, "request", "response", null); - - // then - assertTrue(startAttributes.build().isEmpty()); - assertTrue(endAttributes.build().isEmpty()); - } - - @Test - void shouldSetPeerNameIfItMatches() { - // given - Map peerServiceMapping = new HashMap<>(); - peerServiceMapping.put("example.com", "myService"); - peerServiceMapping.put("1.2.3.4", "someOtherService"); - - PeerServiceAttributesServerExtractor underTest = - new PeerServiceAttributesServerExtractor<>(peerServiceMapping, netAttributesExtractor); - - given(netAttributesExtractor.peerName(any())).willReturn("example.com"); - - // when - AttributesBuilder startAttributes = Attributes.builder(); - underTest.onStart(startAttributes, "request"); - AttributesBuilder endAttributes = Attributes.builder(); - underTest.onEnd(endAttributes, "request", "response", null); - - // then - assertThat(startAttributes.build()) - .containsOnly(entry(SemanticAttributes.PEER_SERVICE, "myService")); - assertThat(endAttributes.build()).isEmpty(); - } - - @Test - void shouldSetPeerIpIfItMatchesAndNameDoesNot() { - // given - Map peerServiceMapping = new HashMap<>(); - peerServiceMapping.put("example.com", "myService"); - peerServiceMapping.put("1.2.3.4", "someOtherService"); - - PeerServiceAttributesServerExtractor underTest = - new PeerServiceAttributesServerExtractor<>(peerServiceMapping, netAttributesExtractor); - - given(netAttributesExtractor.peerName(any())).willReturn("test.com"); - given(netAttributesExtractor.peerIp(any())).willReturn("1.2.3.4"); - - // when - AttributesBuilder startAttributes = Attributes.builder(); - underTest.onStart(startAttributes, "request"); - AttributesBuilder endAttributes = Attributes.builder(); - underTest.onEnd(endAttributes, "request", "response", null); - - // then - assertThat(startAttributes.build()) - .containsOnly(entry(SemanticAttributes.PEER_SERVICE, "someOtherService")); - assertThat(endAttributes.build()).isEmpty(); - } -} From 7d0b619c8e1944c94f1ec7943ad85103e4edd966 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 6 Oct 2021 21:55:24 -0700 Subject: [PATCH 25/26] Fix merge --- .../liberty/dispatcher/LibertyDispatcherSingletons.java | 1 - .../javaagent/instrumentation/undertow/UndertowSingletons.java | 1 - 2 files changed, 2 deletions(-) diff --git a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java index 4becfa6573dd..0256958dfeca 100644 --- a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java +++ b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java @@ -9,7 +9,6 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesExtractor; diff --git a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java index 30e6cd62a4b4..d928f18f42b6 100644 --- a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java +++ b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java @@ -9,7 +9,6 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.instrumentation.api.instrumenter.PeerServiceAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesExtractor; From cbb7b1644e134c78e6a860fb94b0c7fbbe2ad26f Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 7 Oct 2021 13:37:54 -0700 Subject: [PATCH 26/26] Fixes --- .../instrumentation/api/instrumenter/AttributesExtractor.java | 4 ++++ .../instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java index 458aa2fc5b46..1ef45851d4f4 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java @@ -52,6 +52,10 @@ protected static void set( } } + /** + * Returns an {@link AttributesExtractor} implementation that always extracts the provided + * constant value. + */ public static AttributesExtractor constant( AttributeKey attributeKey, T attributeValue) { return new ConstantAttributesExtractor<>(attributeKey, attributeValue); diff --git a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java index f67799bbd983..035c3234ee84 100644 --- a/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java +++ b/instrumentation/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTracingBuilder.java @@ -83,7 +83,7 @@ public DubboTracing build() { } return new DubboTracing( - clientInstrumenterBuilder.newServerInstrumenter(new DubboHeadersGetter()), + serverInstrumenterBuilder.newServerInstrumenter(new DubboHeadersGetter()), clientInstrumenterBuilder.newClientInstrumenter(new DubboHeadersSetter())); } }