From bcafbcb00863f25382dd40c7ec02f455a62fed7b Mon Sep 17 00:00:00 2001 From: Mateusz Rzeszutek Date: Thu, 20 Jan 2022 19:41:41 +0100 Subject: [PATCH] Remove HttpServerTest#extraAttributes() method (#5176) * Remove HttpServerTest#extraAttributes() method * fix ktor tests * fix ratpack and restlet tests * fix servlet2 tests * Fix webflux and vertx tests --- .../AkkaHttpServerInstrumentationTest.groovy | 5 +- .../v1_3/AbstractArmeriaHttpServerTest.groovy | 9 ++-- .../src/test/groovy/DropwizardTest.groovy | 9 ++-- .../src/test/groovy/test/GrailsTest.groovy | 9 ++-- .../GrizzlyFilterchainServerTest.groovy | 1 + .../src/test/groovy/GrizzlyTest.groovy | 1 + .../main/groovy/JaxRsHttpServerTest.groovy | 8 +-- .../src/test/groovy/JettyHandlerTest.groovy | 29 ++++------- .../src/test/groovy/JettyHandlerTest.groovy | 29 ++++------- .../ktor/v1_0/KtorHttpServerTest.groovy | 15 +++--- .../NettyNetServerAttributesExtractor.java | 6 ++- .../NettyNetServerAttributesExtractor.java | 6 ++- .../test/groovy/server/PlayServerTest.groovy | 5 +- .../server/AbstractRatpackRoutesTest.groovy | 33 ++---------- .../server/RatpackAsyncHttpServerTest.groovy | 10 ---- .../server/RatpackForkedHttpServerTest.groovy | 10 ---- .../server/RatpackHttpServerTest.groovy | 10 ---- .../ratpack/server/RatpackRoutesTest.groovy | 10 +--- .../v1_0/AbstractRestletServerTest.groovy | 10 +--- .../v1_0/AbstractServletServerTest.groovy | 16 +++--- .../v2_0/AbstractRestletServerTest.groovy | 10 +--- .../src/test/groovy/JettyServlet2Test.groovy | 9 +--- .../test/groovy/AbstractServlet3Test.groovy | 8 +-- .../src/test/groovy/TomcatServlet3Test.groovy | 12 ----- .../test/groovy/AbstractServlet5Test.groovy | 8 +-- .../src/test/groovy/TomcatServlet5Test.groovy | 9 ++-- .../webflux/server/RouteOnSuccessOrError.java | 1 + .../src/test/groovy/SpringWebfluxTest.groovy | 10 ++++ .../test/boot/SpringBootBasedTest.groovy | 9 ++-- .../test/filter/ServletFilterTest.groovy | 9 ++-- .../test/groovy/Struts2ActionSpanTest.groovy | 8 +-- .../tomcat/v10_0/TomcatAsyncTest.groovy | 9 ++-- .../tomcat/v10_0/TomcatHandlerTest.groovy | 9 ++-- .../tomcat/v7_0/TomcatAsyncTest.groovy | 9 ++-- .../tomcat/v7_0/TomcatHandlerTest.groovy | 9 ++-- .../groovy/UndertowServerDispatchTest.groovy | 10 +--- .../src/test/groovy/UndertowServerTest.groovy | 10 +--- .../VertxReactivePropagationTest.groovy | 3 ++ .../VertxReactivePropagationTest.groovy | 3 ++ .../test/base/HttpServerTest.groovy | 52 +++++++++++++------ 40 files changed, 170 insertions(+), 268 deletions(-) diff --git a/instrumentation/akka/akka-http-10.0/javaagent/src/test/groovy/AkkaHttpServerInstrumentationTest.groovy b/instrumentation/akka/akka-http-10.0/javaagent/src/test/groovy/AkkaHttpServerInstrumentationTest.groovy index 43c8e45b03b2..4b8dd3877df0 100644 --- a/instrumentation/akka/akka-http-10.0/javaagent/src/test/groovy/AkkaHttpServerInstrumentationTest.groovy +++ b/instrumentation/akka/akka-http-10.0/javaagent/src/test/groovy/AkkaHttpServerInstrumentationTest.groovy @@ -6,7 +6,6 @@ import io.opentelemetry.api.common.AttributeKey import io.opentelemetry.instrumentation.test.AgentTestTrait import io.opentelemetry.instrumentation.test.base.HttpServerTest -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes abstract class AkkaHttpServerInstrumentationTest extends HttpServerTest implements AgentTestTrait { @@ -33,9 +32,7 @@ abstract class AkkaHttpServerInstrumentationTest extends HttpServerTest @Override Set> httpAttributes(ServerEndpoint endpoint) { - def attributes = super.httpAttributes(endpoint) - attributes.remove(SemanticAttributes.HTTP_ROUTE) - attributes + [] } } diff --git a/instrumentation/armeria-1.3/testing/src/main/groovy/io/opentelemetry/instrumentation/armeria/v1_3/AbstractArmeriaHttpServerTest.groovy b/instrumentation/armeria-1.3/testing/src/main/groovy/io/opentelemetry/instrumentation/armeria/v1_3/AbstractArmeriaHttpServerTest.groovy index f9826b34071a..0b06697c680e 100644 --- a/instrumentation/armeria-1.3/testing/src/main/groovy/io/opentelemetry/instrumentation/armeria/v1_3/AbstractArmeriaHttpServerTest.groovy +++ b/instrumentation/armeria-1.3/testing/src/main/groovy/io/opentelemetry/instrumentation/armeria/v1_3/AbstractArmeriaHttpServerTest.groovy @@ -52,14 +52,13 @@ abstract class AbstractArmeriaHttpServerTest extends HttpServerTest { } @Override - List> extraAttributes() { - [ + Set> httpAttributes(ServerEndpoint endpoint) { + Set> extra = [ SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH, SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH, - SemanticAttributes.HTTP_SERVER_NAME, - SemanticAttributes.NET_PEER_NAME, - SemanticAttributes.NET_TRANSPORT + SemanticAttributes.HTTP_SERVER_NAME ] + super.httpAttributes(endpoint) + extra } @Override diff --git a/instrumentation/dropwizard/dropwizard-testing/src/test/groovy/DropwizardTest.groovy b/instrumentation/dropwizard/dropwizard-testing/src/test/groovy/DropwizardTest.groovy index 1d4627eec81d..86c719966ba3 100644 --- a/instrumentation/dropwizard/dropwizard-testing/src/test/groovy/DropwizardTest.groovy +++ b/instrumentation/dropwizard/dropwizard-testing/src/test/groovy/DropwizardTest.groovy @@ -63,12 +63,11 @@ class DropwizardTest extends HttpServerTest implements Ag } @Override - List> extraAttributes() { - [ - SemanticAttributes.HTTP_SERVER_NAME, - SemanticAttributes.NET_PEER_NAME, - SemanticAttributes.NET_TRANSPORT + Set> httpAttributes(ServerEndpoint endpoint) { + Set> extra = [ + SemanticAttributes.HTTP_SERVER_NAME ] + super.httpAttributes(endpoint) + extra } // this override is needed because dropwizard reports peer ip as the client ip diff --git a/instrumentation/grails-3.0/javaagent/src/test/groovy/test/GrailsTest.groovy b/instrumentation/grails-3.0/javaagent/src/test/groovy/test/GrailsTest.groovy index 57fb71364ef1..47bc718f0c29 100644 --- a/instrumentation/grails-3.0/javaagent/src/test/groovy/test/GrailsTest.groovy +++ b/instrumentation/grails-3.0/javaagent/src/test/groovy/test/GrailsTest.groovy @@ -57,12 +57,11 @@ class GrailsTest extends HttpServerTest implemen } @Override - List> extraAttributes() { - [ - SemanticAttributes.HTTP_SERVER_NAME, - SemanticAttributes.NET_PEER_NAME, - SemanticAttributes.NET_TRANSPORT + Set> httpAttributes(ServerEndpoint endpoint) { + Set> extra = [ + SemanticAttributes.HTTP_SERVER_NAME ] + super.httpAttributes(endpoint) + extra } @Override diff --git a/instrumentation/grizzly-2.0/javaagent/src/test/groovy/GrizzlyFilterchainServerTest.groovy b/instrumentation/grizzly-2.0/javaagent/src/test/groovy/GrizzlyFilterchainServerTest.groovy index ff744ac694b8..a83dcf622e8f 100644 --- a/instrumentation/grizzly-2.0/javaagent/src/test/groovy/GrizzlyFilterchainServerTest.groovy +++ b/instrumentation/grizzly-2.0/javaagent/src/test/groovy/GrizzlyFilterchainServerTest.groovy @@ -67,6 +67,7 @@ class GrizzlyFilterchainServerTest extends HttpServerTest implements Set> httpAttributes(ServerEndpoint endpoint) { def attributes = super.httpAttributes(endpoint) attributes.remove(SemanticAttributes.HTTP_ROUTE) + attributes.remove(SemanticAttributes.NET_TRANSPORT) attributes } diff --git a/instrumentation/grizzly-2.0/javaagent/src/test/groovy/GrizzlyTest.groovy b/instrumentation/grizzly-2.0/javaagent/src/test/groovy/GrizzlyTest.groovy index 842a117065e5..482d8810fe32 100644 --- a/instrumentation/grizzly-2.0/javaagent/src/test/groovy/GrizzlyTest.groovy +++ b/instrumentation/grizzly-2.0/javaagent/src/test/groovy/GrizzlyTest.groovy @@ -48,6 +48,7 @@ class GrizzlyTest extends HttpServerTest implements AgentTestTrait { Set> httpAttributes(ServerEndpoint endpoint) { def attributes = super.httpAttributes(endpoint) attributes.remove(SemanticAttributes.HTTP_ROUTE) + attributes.remove(SemanticAttributes.NET_TRANSPORT) attributes } diff --git a/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-common/testing/src/main/groovy/JaxRsHttpServerTest.groovy b/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-common/testing/src/main/groovy/JaxRsHttpServerTest.groovy index 664cc359e92a..b28c05f3af3f 100644 --- a/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-common/testing/src/main/groovy/JaxRsHttpServerTest.groovy +++ b/instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-common/testing/src/main/groovy/JaxRsHttpServerTest.groovy @@ -190,11 +190,11 @@ abstract class JaxRsHttpServerTest extends HttpServerTest implements Agent } @Override - List> extraAttributes() { - [ - SemanticAttributes.HTTP_SERVER_NAME, - SemanticAttributes.NET_TRANSPORT + Set> httpAttributes(ServerEndpoint endpoint) { + Set> extra = [ + SemanticAttributes.HTTP_SERVER_NAME ] + super.httpAttributes(endpoint) + extra } @Override diff --git a/instrumentation/jetty/jetty-11.0/javaagent/src/test/groovy/JettyHandlerTest.groovy b/instrumentation/jetty/jetty-11.0/javaagent/src/test/groovy/JettyHandlerTest.groovy index 03eebf390de4..bfb855d14141 100644 --- a/instrumentation/jetty/jetty-11.0/javaagent/src/test/groovy/JettyHandlerTest.groovy +++ b/instrumentation/jetty/jetty-11.0/javaagent/src/test/groovy/JettyHandlerTest.groovy @@ -63,11 +63,16 @@ class JettyHandlerTest extends HttpServerTest implements AgentTestTrait } @Override - List> extraAttributes() { - [ - SemanticAttributes.HTTP_SERVER_NAME, - SemanticAttributes.NET_TRANSPORT - ] + Set> httpAttributes(ServerEndpoint endpoint) { + def attributes = super.httpAttributes(endpoint) + attributes.remove(SemanticAttributes.HTTP_ROUTE) + attributes.add(SemanticAttributes.HTTP_SERVER_NAME) + attributes + } + + @Override + String expectedServerSpanName(ServerEndpoint endpoint) { + "HTTP GET" } @Override @@ -114,7 +119,7 @@ class JettyHandlerTest extends HttpServerTest implements AgentTestTrait case EXCEPTION: throw new Exception(endpoint.body) case INDEXED_CHILD: - INDEXED_CHILD.collectSpanAttributes {name -> request.getParameter(name) } + INDEXED_CHILD.collectSpanAttributes { name -> request.getParameter(name) } response.status = endpoint.status response.writer.print(endpoint.body) break @@ -140,16 +145,4 @@ class JettyHandlerTest extends HttpServerTest implements AgentTestTrait } } } - - @Override - Set> httpAttributes(ServerEndpoint endpoint) { - def attributes = super.httpAttributes(endpoint) - attributes.remove(SemanticAttributes.HTTP_ROUTE) - attributes - } - - @Override - String expectedServerSpanName(ServerEndpoint endpoint) { - "HTTP GET" - } } diff --git a/instrumentation/jetty/jetty-8.0/javaagent/src/test/groovy/JettyHandlerTest.groovy b/instrumentation/jetty/jetty-8.0/javaagent/src/test/groovy/JettyHandlerTest.groovy index 01ddd49e451b..3e5cdec7783a 100644 --- a/instrumentation/jetty/jetty-8.0/javaagent/src/test/groovy/JettyHandlerTest.groovy +++ b/instrumentation/jetty/jetty-8.0/javaagent/src/test/groovy/JettyHandlerTest.groovy @@ -64,11 +64,16 @@ class JettyHandlerTest extends HttpServerTest implements AgentTestTrait } @Override - List> extraAttributes() { - [ - SemanticAttributes.HTTP_SERVER_NAME, - SemanticAttributes.NET_TRANSPORT - ] + Set> httpAttributes(ServerEndpoint endpoint) { + def attributes = super.httpAttributes(endpoint) + attributes.remove(SemanticAttributes.HTTP_ROUTE) + attributes.addAll(SemanticAttributes.HTTP_SERVER_NAME) + attributes + } + + @Override + String expectedServerSpanName(ServerEndpoint endpoint) { + "HTTP GET" } @Override @@ -115,7 +120,7 @@ class JettyHandlerTest extends HttpServerTest implements AgentTestTrait case EXCEPTION: throw new Exception(endpoint.body) case INDEXED_CHILD: - INDEXED_CHILD.collectSpanAttributes {name -> request.getParameter(name) } + INDEXED_CHILD.collectSpanAttributes { name -> request.getParameter(name) } response.status = endpoint.status response.writer.print(endpoint.body) break @@ -141,16 +146,4 @@ class JettyHandlerTest extends HttpServerTest implements AgentTestTrait } } } - - @Override - Set> httpAttributes(ServerEndpoint endpoint) { - def attributes = super.httpAttributes(endpoint) - attributes.remove(SemanticAttributes.HTTP_ROUTE) - attributes - } - - @Override - String expectedServerSpanName(ServerEndpoint endpoint) { - "HTTP GET" - } } diff --git a/instrumentation/ktor-1.0/library/src/test/groovy/io/opentelemetry/instrumentation/ktor/v1_0/KtorHttpServerTest.groovy b/instrumentation/ktor-1.0/library/src/test/groovy/io/opentelemetry/instrumentation/ktor/v1_0/KtorHttpServerTest.groovy index 4b2b5bb569b2..9dba6d008dee 100644 --- a/instrumentation/ktor-1.0/library/src/test/groovy/io/opentelemetry/instrumentation/ktor/v1_0/KtorHttpServerTest.groovy +++ b/instrumentation/ktor-1.0/library/src/test/groovy/io/opentelemetry/instrumentation/ktor/v1_0/KtorHttpServerTest.groovy @@ -39,6 +39,13 @@ class KtorHttpServerTest extends HttpServerTest implements Li true } + @Override + Set> httpAttributes(ServerEndpoint endpoint) { + def attributes = super.httpAttributes(endpoint) + attributes.remove(SemanticAttributes.NET_PEER_PORT) + attributes + } + @Override String expectedServerSpanName(ServerEndpoint endpoint) { def route = expectedHttpRoute(endpoint) @@ -54,12 +61,4 @@ class KtorHttpServerTest extends HttpServerTest implements Li return super.expectedHttpRoute(endpoint) } } - - @Override - List> extraAttributes() { - [ - SemanticAttributes.NET_PEER_NAME, - SemanticAttributes.NET_TRANSPORT - ] - } } diff --git a/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/server/NettyNetServerAttributesExtractor.java b/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/server/NettyNetServerAttributesExtractor.java index 916842b32ac9..0eeb5aab24c6 100644 --- a/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/server/NettyNetServerAttributesExtractor.java +++ b/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/server/NettyNetServerAttributesExtractor.java @@ -5,11 +5,15 @@ package io.opentelemetry.javaagent.instrumentation.netty.v3_8.server; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_TCP; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_UDP; + import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor; import io.opentelemetry.javaagent.instrumentation.netty.v3_8.HttpRequestAndChannel; import java.net.InetSocketAddress; import java.net.SocketAddress; import javax.annotation.Nullable; +import org.jboss.netty.channel.socket.DatagramChannel; import org.jboss.netty.handler.codec.http.HttpResponse; final class NettyNetServerAttributesExtractor @@ -18,7 +22,7 @@ final class NettyNetServerAttributesExtractor @Override @Nullable public String transport(HttpRequestAndChannel requestAndChannel) { - return null; + return requestAndChannel.channel() instanceof DatagramChannel ? IP_UDP : IP_TCP; } @Override diff --git a/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/server/NettyNetServerAttributesExtractor.java b/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/server/NettyNetServerAttributesExtractor.java index 05889d53952d..4e9135345354 100644 --- a/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/server/NettyNetServerAttributesExtractor.java +++ b/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/common/server/NettyNetServerAttributesExtractor.java @@ -5,6 +5,10 @@ package io.opentelemetry.javaagent.instrumentation.netty.common.server; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_TCP; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_UDP; + +import io.netty.channel.socket.DatagramChannel; import io.netty.handler.codec.http.HttpResponse; import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesExtractor; import io.opentelemetry.javaagent.instrumentation.netty.common.HttpRequestAndChannel; @@ -18,7 +22,7 @@ final class NettyNetServerAttributesExtractor @Override @Nullable public String transport(HttpRequestAndChannel requestAndChannel) { - return null; + return requestAndChannel.channel() instanceof DatagramChannel ? IP_UDP : IP_TCP; } @Override diff --git a/instrumentation/play/play-2.6/javaagent/src/test/groovy/server/PlayServerTest.groovy b/instrumentation/play/play-2.6/javaagent/src/test/groovy/server/PlayServerTest.groovy index 12b5984165a8..56dfe5cb1e12 100644 --- a/instrumentation/play/play-2.6/javaagent/src/test/groovy/server/PlayServerTest.groovy +++ b/instrumentation/play/play-2.6/javaagent/src/test/groovy/server/PlayServerTest.groovy @@ -11,7 +11,6 @@ import io.opentelemetry.instrumentation.test.AgentTestTrait import io.opentelemetry.instrumentation.test.asserts.TraceAssert import io.opentelemetry.instrumentation.test.base.HttpServerTest import io.opentelemetry.sdk.trace.data.SpanData -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes import play.BuiltInComponents import play.Mode import play.mvc.Controller @@ -103,9 +102,7 @@ class PlayServerTest extends HttpServerTest implements AgentTestTrait { @Override Set> httpAttributes(ServerEndpoint endpoint) { - def attributes = super.httpAttributes(endpoint) - attributes.remove(SemanticAttributes.HTTP_ROUTE) - attributes + [] } @Override diff --git a/instrumentation/ratpack/ratpack-1.4/testing/src/main/groovy/io/opentelemetry/instrumentation/ratpack/server/AbstractRatpackRoutesTest.groovy b/instrumentation/ratpack/ratpack-1.4/testing/src/main/groovy/io/opentelemetry/instrumentation/ratpack/server/AbstractRatpackRoutesTest.groovy index 7fff744a75aa..b459bcb5d2a7 100644 --- a/instrumentation/ratpack/ratpack-1.4/testing/src/main/groovy/io/opentelemetry/instrumentation/ratpack/server/AbstractRatpackRoutesTest.groovy +++ b/instrumentation/ratpack/ratpack-1.4/testing/src/main/groovy/io/opentelemetry/instrumentation/ratpack/server/AbstractRatpackRoutesTest.groovy @@ -5,7 +5,6 @@ package io.opentelemetry.instrumentation.ratpack.server -import io.opentelemetry.api.common.AttributeKey import io.opentelemetry.instrumentation.test.InstrumentationSpecification import io.opentelemetry.instrumentation.test.utils.PortUtils import io.opentelemetry.semconv.trace.attributes.SemanticAttributes @@ -81,10 +80,6 @@ abstract class AbstractRatpackRoutesTest extends InstrumentationSpecification { abstract boolean hasHandlerSpan() - List> extraAttributes() { - [] - } - def "test bindings for #path"() { when: def resp = client.get(path).aggregate().join() @@ -93,8 +88,6 @@ abstract class AbstractRatpackRoutesTest extends InstrumentationSpecification { resp.status().code() == 200 resp.contentUtf8() == route - def extraAttributes = extraAttributes() - assertTraces(1) { trace(0, 1 + (hasHandlerSpan() ? 1 : 0)) { span(0) { @@ -102,35 +95,19 @@ abstract class AbstractRatpackRoutesTest extends InstrumentationSpecification { kind SERVER hasNoParent() attributes { - if (extraAttributes.contains(SemanticAttributes.NET_TRANSPORT)) { - "$SemanticAttributes.NET_TRANSPORT" IP_TCP - } + "$SemanticAttributes.NET_TRANSPORT" IP_TCP // net.peer.name resolves to "127.0.0.1" on windows which is same as net.peer.ip so then not captured "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } "$SemanticAttributes.NET_PEER_IP" { it == null || it == "127.0.0.1" } "$SemanticAttributes.NET_PEER_PORT" Long + "$SemanticAttributes.HTTP_METHOD" "GET" "$SemanticAttributes.HTTP_STATUS_CODE" 200 "$SemanticAttributes.HTTP_FLAVOR" "1.1" "$SemanticAttributes.HTTP_USER_AGENT" String - - if (extraAttributes.contains(SemanticAttributes.HTTP_URL)) { - "$SemanticAttributes.HTTP_URL" "http://localhost:${app.bindPort}/${path}" - } else { - "$SemanticAttributes.HTTP_SCHEME" "http" - "$SemanticAttributes.HTTP_HOST" "localhost:${app.bindPort}" - "$SemanticAttributes.HTTP_TARGET" "/$path" - } - - if (extraAttributes.contains(SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH)) { - "$SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH" Long - } - if (extraAttributes.contains(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH)) { - "$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" Long - } - if (extraAttributes.contains(SemanticAttributes.HTTP_SERVER_NAME)) { - "$SemanticAttributes.HTTP_SERVER_NAME" String - } + "$SemanticAttributes.HTTP_SCHEME" "http" + "$SemanticAttributes.HTTP_HOST" "localhost:${app.bindPort}" + "$SemanticAttributes.HTTP_TARGET" "/$path" "$SemanticAttributes.HTTP_ROUTE" "/$route" } } diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackAsyncHttpServerTest.groovy b/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackAsyncHttpServerTest.groovy index 267c36be1b28..0920fb4ed7ef 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackAsyncHttpServerTest.groovy +++ b/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackAsyncHttpServerTest.groovy @@ -5,10 +5,8 @@ package io.opentelemetry.instrumentation.ratpack.server -import io.opentelemetry.api.common.AttributeKey import io.opentelemetry.instrumentation.ratpack.RatpackTracing import io.opentelemetry.instrumentation.test.LibraryTestTrait -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes import ratpack.server.RatpackServerSpec class RatpackAsyncHttpServerTest extends AbstractRatpackAsyncHttpServerTest implements LibraryTestTrait { @@ -26,12 +24,4 @@ class RatpackAsyncHttpServerTest extends AbstractRatpackAsyncHttpServerTest impl boolean hasHandlerSpan(ServerEndpoint endpoint) { false } - - @Override - List> extraAttributes() { - return [ - SemanticAttributes.HTTP_ROUTE, - SemanticAttributes.NET_TRANSPORT - ] - } } diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackForkedHttpServerTest.groovy b/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackForkedHttpServerTest.groovy index a6b49da08d54..7416e3fec0be 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackForkedHttpServerTest.groovy +++ b/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackForkedHttpServerTest.groovy @@ -5,10 +5,8 @@ package io.opentelemetry.instrumentation.ratpack.server -import io.opentelemetry.api.common.AttributeKey import io.opentelemetry.instrumentation.ratpack.RatpackTracing import io.opentelemetry.instrumentation.test.LibraryTestTrait -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes import ratpack.server.RatpackServerSpec class RatpackForkedHttpServerTest extends AbstractRatpackForkedHttpServerTest implements LibraryTestTrait { @@ -26,12 +24,4 @@ class RatpackForkedHttpServerTest extends AbstractRatpackForkedHttpServerTest im boolean hasHandlerSpan(ServerEndpoint endpoint) { false } - - @Override - List> extraAttributes() { - return [ - SemanticAttributes.HTTP_ROUTE, - SemanticAttributes.NET_TRANSPORT - ] - } } diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackHttpServerTest.groovy b/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackHttpServerTest.groovy index 88a5ab93b296..b35a7edbaf5f 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackHttpServerTest.groovy +++ b/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackHttpServerTest.groovy @@ -5,10 +5,8 @@ package io.opentelemetry.instrumentation.ratpack.server -import io.opentelemetry.api.common.AttributeKey import io.opentelemetry.instrumentation.ratpack.RatpackTracing import io.opentelemetry.instrumentation.test.LibraryTestTrait -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes import ratpack.server.RatpackServerSpec class RatpackHttpServerTest extends AbstractRatpackHttpServerTest implements LibraryTestTrait { @@ -26,12 +24,4 @@ class RatpackHttpServerTest extends AbstractRatpackHttpServerTest implements Lib boolean hasHandlerSpan(ServerEndpoint endpoint) { false } - - @Override - List> extraAttributes() { - return [ - SemanticAttributes.HTTP_ROUTE, - SemanticAttributes.NET_TRANSPORT - ] - } } diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackRoutesTest.groovy b/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackRoutesTest.groovy index d3834dbdaa04..c39ba8451176 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackRoutesTest.groovy +++ b/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackRoutesTest.groovy @@ -5,10 +5,9 @@ package io.opentelemetry.instrumentation.ratpack.server -import io.opentelemetry.api.common.AttributeKey + import io.opentelemetry.instrumentation.ratpack.RatpackTracing import io.opentelemetry.instrumentation.test.LibraryTestTrait -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes import ratpack.server.RatpackServerSpec class RatpackRoutesTest extends AbstractRatpackRoutesTest implements LibraryTestTrait { @@ -24,11 +23,4 @@ class RatpackRoutesTest extends AbstractRatpackRoutesTest implements LibraryTest boolean hasHandlerSpan() { return false } - - @Override - List> extraAttributes() { - return [ - SemanticAttributes.NET_TRANSPORT - ] - } } diff --git a/instrumentation/restlet/restlet-1.0/testing/src/main/groovy/io/opentelemetry/instrumentation/restlet/v1_0/AbstractRestletServerTest.groovy b/instrumentation/restlet/restlet-1.0/testing/src/main/groovy/io/opentelemetry/instrumentation/restlet/v1_0/AbstractRestletServerTest.groovy index 2bc102d49d4b..b4171d589632 100644 --- a/instrumentation/restlet/restlet-1.0/testing/src/main/groovy/io/opentelemetry/instrumentation/restlet/v1_0/AbstractRestletServerTest.groovy +++ b/instrumentation/restlet/restlet-1.0/testing/src/main/groovy/io/opentelemetry/instrumentation/restlet/v1_0/AbstractRestletServerTest.groovy @@ -5,9 +5,8 @@ package io.opentelemetry.instrumentation.restlet.v1_0 -import io.opentelemetry.api.common.AttributeKey + import io.opentelemetry.instrumentation.test.base.HttpServerTest -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes import org.restlet.Component import org.restlet.Context import org.restlet.Redirector @@ -152,13 +151,6 @@ abstract class AbstractRestletServerTest extends HttpServerTest { } - @Override - List> extraAttributes() { - [ - SemanticAttributes.NET_TRANSPORT - ] - } - @Override boolean testPathParam() { true diff --git a/instrumentation/restlet/restlet-1.0/testing/src/main/groovy/io/opentelemetry/instrumentation/restlet/v1_0/AbstractServletServerTest.groovy b/instrumentation/restlet/restlet-1.0/testing/src/main/groovy/io/opentelemetry/instrumentation/restlet/v1_0/AbstractServletServerTest.groovy index 689a11e19b77..703fb4fdb4cd 100644 --- a/instrumentation/restlet/restlet-1.0/testing/src/main/groovy/io/opentelemetry/instrumentation/restlet/v1_0/AbstractServletServerTest.groovy +++ b/instrumentation/restlet/restlet-1.0/testing/src/main/groovy/io/opentelemetry/instrumentation/restlet/v1_0/AbstractServletServerTest.groovy @@ -46,14 +46,6 @@ abstract class AbstractServletServerTest extends HttpServerTest { return jettyServer } - @Override - List> extraAttributes() { - [ - SemanticAttributes.NET_TRANSPORT, - SemanticAttributes.HTTP_SERVER_NAME - ] - } - @Override void stopServer(Server server) { server.stop() @@ -70,6 +62,14 @@ abstract class AbstractServletServerTest extends HttpServerTest { true } + @Override + Set> httpAttributes(ServerEndpoint endpoint) { + Set> extra = [ + SemanticAttributes.HTTP_SERVER_NAME + ] + super.httpAttributes(endpoint) + extra + } + @Override String expectedHttpRoute(ServerEndpoint endpoint) { switch (endpoint) { diff --git a/instrumentation/restlet/restlet-2.0/testing/src/main/groovy/io/opentelemetry/instrumentation/restlet/v2_0/AbstractRestletServerTest.groovy b/instrumentation/restlet/restlet-2.0/testing/src/main/groovy/io/opentelemetry/instrumentation/restlet/v2_0/AbstractRestletServerTest.groovy index 56b244bdd037..3be858294370 100644 --- a/instrumentation/restlet/restlet-2.0/testing/src/main/groovy/io/opentelemetry/instrumentation/restlet/v2_0/AbstractRestletServerTest.groovy +++ b/instrumentation/restlet/restlet-2.0/testing/src/main/groovy/io/opentelemetry/instrumentation/restlet/v2_0/AbstractRestletServerTest.groovy @@ -5,9 +5,8 @@ package io.opentelemetry.instrumentation.restlet.v2_0 -import io.opentelemetry.api.common.AttributeKey + import io.opentelemetry.instrumentation.test.base.HttpServerTest -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes import org.restlet.Component import org.restlet.Context import org.restlet.Request @@ -165,13 +164,6 @@ abstract class AbstractRestletServerTest extends HttpServerTest { } - @Override - List> extraAttributes() { - [ - SemanticAttributes.NET_TRANSPORT - ] - } - @Override boolean testPathParam() { true diff --git a/instrumentation/servlet/servlet-2.2/javaagent/src/test/groovy/JettyServlet2Test.groovy b/instrumentation/servlet/servlet-2.2/javaagent/src/test/groovy/JettyServlet2Test.groovy index ac52e59955b8..fc99cdc731bd 100644 --- a/instrumentation/servlet/servlet-2.2/javaagent/src/test/groovy/JettyServlet2Test.groovy +++ b/instrumentation/servlet/servlet-2.2/javaagent/src/test/groovy/JettyServlet2Test.groovy @@ -73,17 +73,10 @@ class JettyServlet2Test extends HttpServerTest implements AgentTestTrait @Override Set> httpAttributes(ServerEndpoint endpoint) { - def attributes = super.httpAttributes(endpoint) - attributes.remove(SemanticAttributes.HTTP_ROUTE) - attributes - } - - @Override - List> extraAttributes() { [ SemanticAttributes.HTTP_SERVER_NAME, SemanticAttributes.NET_TRANSPORT - ] + ] as Set } @Override diff --git a/instrumentation/servlet/servlet-3.0/javaagent/src/test/groovy/AbstractServlet3Test.groovy b/instrumentation/servlet/servlet-3.0/javaagent/src/test/groovy/AbstractServlet3Test.groovy index 73d4c48bd21e..3f229014acdb 100644 --- a/instrumentation/servlet/servlet-3.0/javaagent/src/test/groovy/AbstractServlet3Test.groovy +++ b/instrumentation/servlet/servlet-3.0/javaagent/src/test/groovy/AbstractServlet3Test.groovy @@ -72,11 +72,11 @@ abstract class AbstractServlet3Test extends HttpServerTest> extraAttributes() { - [ - SemanticAttributes.HTTP_SERVER_NAME, - SemanticAttributes.NET_TRANSPORT + Set> httpAttributes(ServerEndpoint endpoint) { + Set> extra = [ + SemanticAttributes.HTTP_SERVER_NAME ] + super.httpAttributes(endpoint) + extra } @Override diff --git a/instrumentation/servlet/servlet-3.0/javaagent/src/test/groovy/TomcatServlet3Test.groovy b/instrumentation/servlet/servlet-3.0/javaagent/src/test/groovy/TomcatServlet3Test.groovy index 6e78836b233d..0a8f5426556d 100644 --- a/instrumentation/servlet/servlet-3.0/javaagent/src/test/groovy/TomcatServlet3Test.groovy +++ b/instrumentation/servlet/servlet-3.0/javaagent/src/test/groovy/TomcatServlet3Test.groovy @@ -3,9 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import io.opentelemetry.api.common.AttributeKey import io.opentelemetry.instrumentation.test.asserts.TraceAssert -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes import io.opentelemetry.testing.internal.armeria.common.AggregatedHttpResponse import org.apache.catalina.AccessLog import org.apache.catalina.Context @@ -41,16 +39,6 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue @Unroll abstract class TomcatServlet3Test extends AbstractServlet3Test { - @Override - List> extraAttributes() { - [ - SemanticAttributes.HTTP_SERVER_NAME, - SemanticAttributes.NET_PEER_NAME, - SemanticAttributes.NET_TRANSPORT - ] - } - - @Override Class expectedExceptionClass() { ServletException diff --git a/instrumentation/servlet/servlet-5.0/javaagent/src/test/groovy/AbstractServlet5Test.groovy b/instrumentation/servlet/servlet-5.0/javaagent/src/test/groovy/AbstractServlet5Test.groovy index a4c8f54b936f..2e4b62fcc31c 100644 --- a/instrumentation/servlet/servlet-5.0/javaagent/src/test/groovy/AbstractServlet5Test.groovy +++ b/instrumentation/servlet/servlet-5.0/javaagent/src/test/groovy/AbstractServlet5Test.groovy @@ -80,11 +80,11 @@ abstract class AbstractServlet5Test extends HttpServerTest> extraAttributes() { - [ - SemanticAttributes.HTTP_SERVER_NAME, - SemanticAttributes.NET_TRANSPORT + Set> httpAttributes(ServerEndpoint endpoint) { + Set> extra = [ + SemanticAttributes.HTTP_SERVER_NAME ] + super.httpAttributes(endpoint) + extra } @Override diff --git a/instrumentation/servlet/servlet-5.0/javaagent/src/test/groovy/TomcatServlet5Test.groovy b/instrumentation/servlet/servlet-5.0/javaagent/src/test/groovy/TomcatServlet5Test.groovy index c5f8b5bb01e3..a97a08bd5491 100644 --- a/instrumentation/servlet/servlet-5.0/javaagent/src/test/groovy/TomcatServlet5Test.groovy +++ b/instrumentation/servlet/servlet-5.0/javaagent/src/test/groovy/TomcatServlet5Test.groovy @@ -42,12 +42,11 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue abstract class TomcatServlet5Test extends AbstractServlet5Test { @Override - List> extraAttributes() { - [ - SemanticAttributes.HTTP_SERVER_NAME, - SemanticAttributes.NET_PEER_NAME, - SemanticAttributes.NET_TRANSPORT + Set> httpAttributes(ServerEndpoint endpoint) { + Set> extra = [ + SemanticAttributes.HTTP_SERVER_NAME ] + super.httpAttributes(endpoint) + extra } @Override diff --git a/instrumentation/spring/spring-webflux-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/server/RouteOnSuccessOrError.java b/instrumentation/spring/spring-webflux-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/server/RouteOnSuccessOrError.java index 069b49587a41..e3b886fdfcce 100644 --- a/instrumentation/spring/spring-webflux-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/server/RouteOnSuccessOrError.java +++ b/instrumentation/spring/spring-webflux-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/server/RouteOnSuccessOrError.java @@ -36,6 +36,7 @@ public void accept(HandlerFunction handler, Throwable throwable) { if (context != null) { Span serverSpan = ServerSpan.fromContextOrNull(context); if (serverSpan != null) { + // TODO should update SERVER span name/route using ServerSpanNaming serverSpan.updateName(ServletContextPath.prepend(context, parseRoute(predicateString))); } } diff --git a/instrumentation/spring/spring-webflux-5.0/javaagent/src/test/groovy/SpringWebfluxTest.groovy b/instrumentation/spring/spring-webflux-5.0/javaagent/src/test/groovy/SpringWebfluxTest.groovy index a8d6ac02d459..516b5aa5974b 100644 --- a/instrumentation/spring/spring-webflux-5.0/javaagent/src/test/groovy/SpringWebfluxTest.groovy +++ b/instrumentation/spring/spring-webflux-5.0/javaagent/src/test/groovy/SpringWebfluxTest.groovy @@ -28,6 +28,7 @@ import static io.opentelemetry.api.trace.SpanKind.INTERNAL import static io.opentelemetry.api.trace.SpanKind.SERVER import static io.opentelemetry.api.trace.StatusCode.ERROR import static io.opentelemetry.api.trace.StatusCode.UNSET +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_TCP @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = [SpringWebFluxTestApplication, ForceNettyAutoConfiguration]) class SpringWebfluxTest extends AgentInstrumentationSpecification { @@ -79,6 +80,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification { kind SERVER hasNoParent() attributes { + "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" Long @@ -144,6 +146,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification { kind SERVER hasNoParent() attributes { + "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" Long @@ -229,6 +232,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification { kind SERVER hasNoParent() attributes { + "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" Long @@ -292,6 +296,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification { hasNoParent() status UNSET attributes { + "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" Long @@ -334,6 +339,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification { kind SERVER hasNoParent() attributes { + "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" Long @@ -381,6 +387,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification { status ERROR hasNoParent() attributes { + "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" Long @@ -443,6 +450,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification { kind SERVER hasNoParent() attributes { + "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" Long @@ -473,6 +481,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification { kind SERVER hasNoParent() attributes { + "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" Long @@ -518,6 +527,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification { kind SERVER hasNoParent() attributes { + "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" Long diff --git a/instrumentation/spring/spring-webmvc-3.1/javaagent/src/test/groovy/test/boot/SpringBootBasedTest.groovy b/instrumentation/spring/spring-webmvc-3.1/javaagent/src/test/groovy/test/boot/SpringBootBasedTest.groovy index 041f1494c56b..040143323fb3 100644 --- a/instrumentation/spring/spring-webmvc-3.1/javaagent/src/test/groovy/test/boot/SpringBootBasedTest.groovy +++ b/instrumentation/spring/spring-webmvc-3.1/javaagent/src/test/groovy/test/boot/SpringBootBasedTest.groovy @@ -54,12 +54,11 @@ class SpringBootBasedTest extends HttpServerTest } @Override - List> extraAttributes() { - [ - SemanticAttributes.HTTP_SERVER_NAME, - SemanticAttributes.NET_PEER_NAME, - SemanticAttributes.NET_TRANSPORT + Set> httpAttributes(ServerEndpoint endpoint) { + Set> extra = [ + SemanticAttributes.HTTP_SERVER_NAME ] + super.httpAttributes(endpoint) + extra } @Override diff --git a/instrumentation/spring/spring-webmvc-3.1/javaagent/src/test/groovy/test/filter/ServletFilterTest.groovy b/instrumentation/spring/spring-webmvc-3.1/javaagent/src/test/groovy/test/filter/ServletFilterTest.groovy index 6ac9a61f8ea8..df491c0809da 100644 --- a/instrumentation/spring/spring-webmvc-3.1/javaagent/src/test/groovy/test/filter/ServletFilterTest.groovy +++ b/instrumentation/spring/spring-webmvc-3.1/javaagent/src/test/groovy/test/filter/ServletFilterTest.groovy @@ -39,12 +39,11 @@ class ServletFilterTest extends HttpServerTest i } @Override - List> extraAttributes() { - [ - SemanticAttributes.HTTP_SERVER_NAME, - SemanticAttributes.NET_PEER_NAME, - SemanticAttributes.NET_TRANSPORT + Set> httpAttributes(ServerEndpoint endpoint) { + Set> extra = [ + SemanticAttributes.HTTP_SERVER_NAME ] + super.httpAttributes(endpoint) + extra } @Override diff --git a/instrumentation/struts-2.3/javaagent/src/test/groovy/Struts2ActionSpanTest.groovy b/instrumentation/struts-2.3/javaagent/src/test/groovy/Struts2ActionSpanTest.groovy index 44f943cf4f6c..217b102263e2 100644 --- a/instrumentation/struts-2.3/javaagent/src/test/groovy/Struts2ActionSpanTest.groovy +++ b/instrumentation/struts-2.3/javaagent/src/test/groovy/Struts2ActionSpanTest.groovy @@ -30,11 +30,11 @@ import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEn class Struts2ActionSpanTest extends HttpServerTest implements AgentTestTrait { @Override - List> extraAttributes() { - [ - SemanticAttributes.HTTP_SERVER_NAME, - SemanticAttributes.NET_TRANSPORT + Set> httpAttributes(ServerEndpoint endpoint) { + Set> extra = [ + SemanticAttributes.HTTP_SERVER_NAME ] + super.httpAttributes(endpoint) + extra } @Override diff --git a/instrumentation/tomcat/tomcat-10.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat/v10_0/TomcatAsyncTest.groovy b/instrumentation/tomcat/tomcat-10.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat/v10_0/TomcatAsyncTest.groovy index 7d5e75e4cc55..e2ae37404125 100644 --- a/instrumentation/tomcat/tomcat-10.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat/v10_0/TomcatAsyncTest.groovy +++ b/instrumentation/tomcat/tomcat-10.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat/v10_0/TomcatAsyncTest.groovy @@ -110,12 +110,11 @@ class TomcatAsyncTest extends HttpServerTest implements AgentTestTrait { } @Override - List> extraAttributes() { - [ - SemanticAttributes.HTTP_SERVER_NAME, - SemanticAttributes.NET_PEER_NAME, - SemanticAttributes.NET_TRANSPORT + Set> httpAttributes(ServerEndpoint endpoint) { + Set> extra = [ + SemanticAttributes.HTTP_SERVER_NAME ] + super.httpAttributes(endpoint) + extra } @Override diff --git a/instrumentation/tomcat/tomcat-10.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat/v10_0/TomcatHandlerTest.groovy b/instrumentation/tomcat/tomcat-10.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat/v10_0/TomcatHandlerTest.groovy index 42465803d4a8..7e1b919aabcb 100644 --- a/instrumentation/tomcat/tomcat-10.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat/v10_0/TomcatHandlerTest.groovy +++ b/instrumentation/tomcat/tomcat-10.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat/v10_0/TomcatHandlerTest.groovy @@ -75,12 +75,11 @@ class TomcatHandlerTest extends HttpServerTest implements AgentTestTrait } @Override - List> extraAttributes() { - [ - SemanticAttributes.HTTP_SERVER_NAME, - SemanticAttributes.NET_PEER_NAME, - SemanticAttributes.NET_TRANSPORT + Set> httpAttributes(ServerEndpoint endpoint) { + Set> extra = [ + SemanticAttributes.HTTP_SERVER_NAME ] + super.httpAttributes(endpoint) + extra } @Override diff --git a/instrumentation/tomcat/tomcat-7.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat/v7_0/TomcatAsyncTest.groovy b/instrumentation/tomcat/tomcat-7.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat/v7_0/TomcatAsyncTest.groovy index 0508b6f9d50e..c0a955b1a68f 100644 --- a/instrumentation/tomcat/tomcat-7.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat/v7_0/TomcatAsyncTest.groovy +++ b/instrumentation/tomcat/tomcat-7.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat/v7_0/TomcatAsyncTest.groovy @@ -110,12 +110,11 @@ class TomcatAsyncTest extends HttpServerTest implements AgentTestTrait { } @Override - List> extraAttributes() { - [ - SemanticAttributes.HTTP_SERVER_NAME, - SemanticAttributes.NET_PEER_NAME, - SemanticAttributes.NET_TRANSPORT + Set> httpAttributes(ServerEndpoint endpoint) { + Set> extra = [ + SemanticAttributes.HTTP_SERVER_NAME ] + super.httpAttributes(endpoint) + extra } @Override diff --git a/instrumentation/tomcat/tomcat-7.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat/v7_0/TomcatHandlerTest.groovy b/instrumentation/tomcat/tomcat-7.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat/v7_0/TomcatHandlerTest.groovy index 4b65c6bdc199..b63e7a115024 100644 --- a/instrumentation/tomcat/tomcat-7.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat/v7_0/TomcatHandlerTest.groovy +++ b/instrumentation/tomcat/tomcat-7.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/tomcat/v7_0/TomcatHandlerTest.groovy @@ -75,12 +75,11 @@ class TomcatHandlerTest extends HttpServerTest implements AgentTestTrait } @Override - List> extraAttributes() { - [ - SemanticAttributes.HTTP_SERVER_NAME, - SemanticAttributes.NET_PEER_NAME, - SemanticAttributes.NET_TRANSPORT + Set> httpAttributes(ServerEndpoint endpoint) { + Set> extra = [ + SemanticAttributes.HTTP_SERVER_NAME ] + super.httpAttributes(endpoint) + extra } @Override diff --git a/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerDispatchTest.groovy b/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerDispatchTest.groovy index aefe85cb0ee9..b65d9b0bd946 100644 --- a/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerDispatchTest.groovy +++ b/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerDispatchTest.groovy @@ -100,6 +100,7 @@ class UndertowServerDispatchTest extends HttpServerTest implements Age Set> httpAttributes(ServerEndpoint endpoint) { def attributes = super.httpAttributes(endpoint) attributes.remove(SemanticAttributes.HTTP_ROUTE) + attributes.add(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH) attributes } @@ -107,13 +108,4 @@ class UndertowServerDispatchTest extends HttpServerTest implements Age String expectedServerSpanName(ServerEndpoint endpoint) { return "HTTP GET" } - - @Override - List> extraAttributes() { - [ - SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH, - SemanticAttributes.NET_PEER_NAME, - SemanticAttributes.NET_TRANSPORT - ] - } } diff --git a/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy b/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy index 9b411bcf1288..d55a62d24aa6 100644 --- a/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy +++ b/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy @@ -109,6 +109,7 @@ class UndertowServerTest extends HttpServerTest implements AgentTestTr Set> httpAttributes(ServerEndpoint endpoint) { def attributes = super.httpAttributes(endpoint) attributes.remove(SemanticAttributes.HTTP_ROUTE) + attributes.add(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH) attributes } @@ -117,15 +118,6 @@ class UndertowServerTest extends HttpServerTest implements AgentTestTr return "HTTP GET" } - @Override - List> extraAttributes() { - [ - SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH, - SemanticAttributes.NET_PEER_NAME, - SemanticAttributes.NET_TRANSPORT - ] - } - def "test send response"() { setup: def uri = address.resolve("sendResponse") diff --git a/instrumentation/vertx/vertx-reactive-3.5/javaagent/src/latestDepTest/groovy/VertxReactivePropagationTest.groovy b/instrumentation/vertx/vertx-reactive-3.5/javaagent/src/latestDepTest/groovy/VertxReactivePropagationTest.groovy index c3c0a5d363ad..48c37eae3cd2 100644 --- a/instrumentation/vertx/vertx-reactive-3.5/javaagent/src/latestDepTest/groovy/VertxReactivePropagationTest.groovy +++ b/instrumentation/vertx/vertx-reactive-3.5/javaagent/src/latestDepTest/groovy/VertxReactivePropagationTest.groovy @@ -24,6 +24,7 @@ import static VertxReactiveWebServer.TEST_REQUEST_ID_PARAMETER import static io.opentelemetry.api.trace.SpanKind.CLIENT import static io.opentelemetry.api.trace.SpanKind.SERVER import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_TCP class VertxReactivePropagationTest extends AgentInstrumentationSpecification { @Shared @@ -62,6 +63,7 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification { kind SERVER hasNoParent() attributes { + "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } "$SemanticAttributes.NET_PEER_PORT" Long "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" @@ -151,6 +153,7 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification { kind SERVER childOf(span(0)) attributes { + "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } "$SemanticAttributes.NET_PEER_PORT" Long "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" diff --git a/instrumentation/vertx/vertx-reactive-3.5/javaagent/src/version35Test/groovy/VertxReactivePropagationTest.groovy b/instrumentation/vertx/vertx-reactive-3.5/javaagent/src/version35Test/groovy/VertxReactivePropagationTest.groovy index c3c0a5d363ad..48c37eae3cd2 100644 --- a/instrumentation/vertx/vertx-reactive-3.5/javaagent/src/version35Test/groovy/VertxReactivePropagationTest.groovy +++ b/instrumentation/vertx/vertx-reactive-3.5/javaagent/src/version35Test/groovy/VertxReactivePropagationTest.groovy @@ -24,6 +24,7 @@ import static VertxReactiveWebServer.TEST_REQUEST_ID_PARAMETER import static io.opentelemetry.api.trace.SpanKind.CLIENT import static io.opentelemetry.api.trace.SpanKind.SERVER import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_TCP class VertxReactivePropagationTest extends AgentInstrumentationSpecification { @Shared @@ -62,6 +63,7 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification { kind SERVER hasNoParent() attributes { + "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } "$SemanticAttributes.NET_PEER_PORT" Long "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" @@ -151,6 +153,7 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification { kind SERVER childOf(span(0)) attributes { + "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } "$SemanticAttributes.NET_PEER_PORT" Long "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" diff --git a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy index 263abcc520b0..cdd7fbad23e6 100644 --- a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy +++ b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy @@ -159,12 +159,12 @@ abstract class HttpServerTest extends InstrumentationSpecification imple /** A list of additional HTTP server span attributes extracted by the instrumentation per URI. */ Set> httpAttributes(ServerEndpoint endpoint) { - [SemanticAttributes.HTTP_ROUTE] as Set - } - - // TODO: remove that method and use httpAttributes everywhere; similar to HttpClientTest - List> extraAttributes() { - [] + [ + SemanticAttributes.HTTP_ROUTE, + SemanticAttributes.NET_TRANSPORT, + SemanticAttributes.NET_PEER_NAME, + SemanticAttributes.NET_PEER_PORT + ] as Set } enum ServerEndpoint { @@ -663,7 +663,7 @@ abstract class HttpServerTest extends InstrumentationSpecification imple // parent span must be cast otherwise it breaks debugging classloading (junit loads it early) void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) { - def httpAttributes = extraAttributes() + this.httpAttributes(endpoint) + def httpAttributes = this.httpAttributes(endpoint) trace.span(index) { name expectedServerSpanName(endpoint) kind SpanKind.SERVER // can't use static import because of SERVER type parameter @@ -690,10 +690,19 @@ abstract class HttpServerTest extends InstrumentationSpecification imple if (httpAttributes.contains(SemanticAttributes.NET_TRANSPORT)) { "$SemanticAttributes.NET_TRANSPORT" IP_TCP } - // net.peer.name resolves to "127.0.0.1" on windows which is same as net.peer.ip so then not captured - "$SemanticAttributes.NET_PEER_NAME" { it == null || it == address.host } - "$SemanticAttributes.NET_PEER_PORT" { it == null || (it instanceof Long && it != port) } - "$SemanticAttributes.NET_PEER_IP" { it == null || it == peerIp(endpoint) } // Optional + if (httpAttributes.contains(SemanticAttributes.NET_PEER_NAME)) { + // net.peer.name resolves to "127.0.0.1" on windows which is same as net.peer.ip so then not captured + "$SemanticAttributes.NET_PEER_NAME" { it == null || it == address.host } + } + if (httpAttributes.contains(SemanticAttributes.NET_PEER_PORT)) { + "$SemanticAttributes.NET_PEER_PORT" { (it instanceof Long && it.intValue() != port) } + } + if (httpAttributes.contains(SemanticAttributes.NET_PEER_IP)) { + "$SemanticAttributes.NET_PEER_IP" { it == peerIp(endpoint) } + } else { + "$SemanticAttributes.NET_PEER_IP" { it == null || it == peerIp(endpoint) } + // Optional + } "$SemanticAttributes.HTTP_CLIENT_IP" { it == null || it == TEST_CLIENT_IP } "$SemanticAttributes.HTTP_METHOD" method @@ -701,8 +710,8 @@ abstract class HttpServerTest extends InstrumentationSpecification imple "$SemanticAttributes.HTTP_FLAVOR" { it == "1.1" || it == "2.0" } "$SemanticAttributes.HTTP_USER_AGENT" TEST_USER_AGENT - "$SemanticAttributes.HTTP_HOST" { it == "localhost" || it == "localhost:${port}" } "$SemanticAttributes.HTTP_SCHEME" "http" + "$SemanticAttributes.HTTP_HOST" { it == "localhost" || it == "localhost:${port}" } "$SemanticAttributes.HTTP_TARGET" endpoint.resolvePath(address).getPath() + "${endpoint == QUERY_PARAM ? "?${endpoint.body}" : ""}" if (httpAttributes.contains(SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH)) { @@ -737,7 +746,7 @@ abstract class HttpServerTest extends InstrumentationSpecification imple void indexedServerSpan(TraceAssert trace, Object parent, int requestId) { ServerEndpoint endpoint = INDEXED_CHILD - def httpAttributes = extraAttributes() + this.httpAttributes(endpoint) + def httpAttributes = this.httpAttributes(endpoint) trace.span(1) { name expectedServerSpanName(endpoint) kind SpanKind.SERVER // can't use static import because of SERVER type parameter @@ -746,10 +755,19 @@ abstract class HttpServerTest extends InstrumentationSpecification imple if (httpAttributes.contains(SemanticAttributes.NET_TRANSPORT)) { "$SemanticAttributes.NET_TRANSPORT" IP_TCP } - // net.peer.name resolves to "127.0.0.1" on windows which is same as net.peer.ip so then not captured - "$SemanticAttributes.NET_PEER_NAME" { (it == null || it == address.host) } - "$SemanticAttributes.NET_PEER_PORT" { it == null || it instanceof Long } - "$SemanticAttributes.NET_PEER_IP" { it == null || it == peerIp(endpoint) } // Optional + if (httpAttributes.contains(SemanticAttributes.NET_PEER_NAME)) { + // net.peer.name resolves to "127.0.0.1" on windows which is same as net.peer.ip so then not captured + "$SemanticAttributes.NET_PEER_NAME" { it == null || it == address.host } + } + if (httpAttributes.contains(SemanticAttributes.NET_PEER_PORT)) { + "$SemanticAttributes.NET_PEER_PORT" { (it instanceof Long && it.intValue() != port) } + } + if (httpAttributes.contains(SemanticAttributes.NET_PEER_IP)) { + "$SemanticAttributes.NET_PEER_IP" { it == peerIp(endpoint) } + } else { + "$SemanticAttributes.NET_PEER_IP" { it == null || it == peerIp(endpoint) } + // Optional + } "$SemanticAttributes.HTTP_CLIENT_IP" { it == null || it == TEST_CLIENT_IP } "$SemanticAttributes.HTTP_METHOD" "GET"