diff --git a/instrumentation/akka-http-10.0/src/test/groovy/AkkaHttpServerInstrumentationTest.groovy b/instrumentation/akka-http-10.0/src/test/groovy/AkkaHttpServerInstrumentationTest.groovy index 543d8a4663..9ae8412e92 100644 --- a/instrumentation/akka-http-10.0/src/test/groovy/AkkaHttpServerInstrumentationTest.groovy +++ b/instrumentation/akka-http-10.0/src/test/groovy/AkkaHttpServerInstrumentationTest.groovy @@ -24,7 +24,7 @@ abstract class AkkaHttpServerInstrumentationTest extends HttpServerTest // } @Override - String expectedServerSpanName(String method, ServerEndpoint endpoint) { + String expectedServerSpanName(ServerEndpoint endpoint) { return "akka.request" } } diff --git a/instrumentation/dropwizard-testing/src/test/groovy/DropwizardTest.groovy b/instrumentation/dropwizard-testing/src/test/groovy/DropwizardTest.groovy index 513699959d..6f4f340b6e 100644 --- a/instrumentation/dropwizard-testing/src/test/groovy/DropwizardTest.groovy +++ b/instrumentation/dropwizard-testing/src/test/groovy/DropwizardTest.groovy @@ -87,6 +87,7 @@ class DropwizardTest extends HttpServerTest { } } + // this override is needed because dropwizard reports peer ip as the client ip @Override void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) { trace.span(index) { diff --git a/instrumentation/finatra-2.9/src/test/groovy/FinatraServerTest.groovy b/instrumentation/finatra-2.9/src/test/groovy/FinatraServerTest.groovy index 804843aac6..0ff831527b 100644 --- a/instrumentation/finatra-2.9/src/test/groovy/FinatraServerTest.groovy +++ b/instrumentation/finatra-2.9/src/test/groovy/FinatraServerTest.groovy @@ -3,10 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.PATH_PARAM import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS import static io.opentelemetry.trace.Span.Kind.INTERNAL -import static io.opentelemetry.trace.Span.Kind.SERVER import com.twitter.finatra.http.HttpServer import com.twitter.util.Await @@ -15,7 +13,6 @@ import com.twitter.util.Duration import io.opentelemetry.instrumentation.test.asserts.TraceAssert import io.opentelemetry.instrumentation.test.base.HttpServerTest import io.opentelemetry.sdk.trace.data.SpanData -import io.opentelemetry.trace.attributes.SemanticAttributes import java.util.concurrent.TimeoutException class FinatraServerTest extends HttpServerTest { @@ -83,29 +80,4 @@ class FinatraServerTest extends HttpServerTest { } } } - - @Override - void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) { - trace.span(index) { - name endpoint == PATH_PARAM ? "/path/:id/param" : endpoint.resolvePath(address).path - kind SERVER - errored endpoint.errored - if (parentID != null) { - traceId traceID - parentSpanId parentID - } else { - hasNoParent() - } - attributes { - "${SemanticAttributes.NET_PEER_PORT.key()}" Long - "${SemanticAttributes.NET_PEER_IP.key()}" { it == null || it == "127.0.0.1" } // Optional - "${SemanticAttributes.HTTP_URL.key()}" { it == "${endpoint.resolve(address)}" || it == "${endpoint.resolveWithoutFragment(address)}" } - "${SemanticAttributes.HTTP_METHOD.key()}" method - "${SemanticAttributes.HTTP_STATUS_CODE.key()}" endpoint.status - "${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1" - "${SemanticAttributes.HTTP_USER_AGENT.key()}" TEST_USER_AGENT - "${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP - } - } - } } diff --git a/instrumentation/grizzly-2.0/src/test/groovy/GrizzlyFilterchainServerTest.groovy b/instrumentation/grizzly-2.0/src/test/groovy/GrizzlyFilterchainServerTest.groovy index 046e64977e..df36c883ea 100644 --- a/instrumentation/grizzly-2.0/src/test/groovy/GrizzlyFilterchainServerTest.groovy +++ b/instrumentation/grizzly-2.0/src/test/groovy/GrizzlyFilterchainServerTest.groovy @@ -205,7 +205,7 @@ class GrizzlyFilterchainServerTest extends HttpServerTest { } @Override - String expectedServerSpanName(String method, ServerEndpoint endpoint) { + String expectedServerSpanName(ServerEndpoint endpoint) { return "HttpCodecFilter.handleRead" } diff --git a/instrumentation/grizzly-2.0/src/test/groovy/GrizzlyTest.groovy b/instrumentation/grizzly-2.0/src/test/groovy/GrizzlyTest.groovy index cbe240bdd1..439e1400d3 100644 --- a/instrumentation/grizzly-2.0/src/test/groovy/GrizzlyTest.groovy +++ b/instrumentation/grizzly-2.0/src/test/groovy/GrizzlyTest.groovy @@ -96,7 +96,7 @@ class GrizzlyTest extends HttpServerTest { } @Override - String expectedServerSpanName(String method, ServerEndpoint endpoint) { + String expectedServerSpanName(ServerEndpoint endpoint) { return "HttpCodecFilter.handleRead" } diff --git a/instrumentation/jetty-8.0/src/test/groovy/JettyHandlerTest.groovy b/instrumentation/jetty-8.0/src/test/groovy/JettyHandlerTest.groovy index 154b8ea22f..9013d465e3 100644 --- a/instrumentation/jetty-8.0/src/test/groovy/JettyHandlerTest.groovy +++ b/instrumentation/jetty-8.0/src/test/groovy/JettyHandlerTest.groovy @@ -9,11 +9,8 @@ import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEn import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.REDIRECT import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS -import static io.opentelemetry.trace.Span.Kind.SERVER -import io.opentelemetry.instrumentation.test.asserts.TraceAssert import io.opentelemetry.instrumentation.test.base.HttpServerTest -import io.opentelemetry.trace.attributes.SemanticAttributes import javax.servlet.DispatcherType import javax.servlet.ServletException import javax.servlet.http.HttpServletRequest @@ -110,30 +107,7 @@ class JettyHandlerTest extends HttpServerTest { } @Override - void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) { - trace.span(index) { - name "TestHandler.handle" - kind SERVER - errored endpoint.errored - if (endpoint == EXCEPTION) { - errorEvent(Exception, EXCEPTION.body) - } - if (parentID != null) { - traceId traceID - parentSpanId parentID - } else { - hasNoParent() - } - attributes { - "${SemanticAttributes.NET_PEER_IP.key()}" "127.0.0.1" - "${SemanticAttributes.NET_PEER_PORT.key()}" Long - "${SemanticAttributes.HTTP_URL.key()}" { it == "${endpoint.resolve(address)}" || it == "${endpoint.resolveWithoutFragment(address)}" } - "${SemanticAttributes.HTTP_METHOD.key()}" method - "${SemanticAttributes.HTTP_STATUS_CODE.key()}" endpoint.status - "${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1" - "${SemanticAttributes.HTTP_USER_AGENT.key()}" TEST_USER_AGENT - "${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP - } - } + String expectedServerSpanName(ServerEndpoint endpoint) { + "TestHandler.handle" } } diff --git a/instrumentation/netty/netty-3.8/src/latestDepTest/groovy/Netty38ServerTest.groovy b/instrumentation/netty/netty-3.8/src/latestDepTest/groovy/Netty38ServerTest.groovy index 90bcf7e7af..06367800e6 100644 --- a/instrumentation/netty/netty-3.8/src/latestDepTest/groovy/Netty38ServerTest.groovy +++ b/instrumentation/netty/netty-3.8/src/latestDepTest/groovy/Netty38ServerTest.groovy @@ -141,7 +141,7 @@ class Netty38ServerTest extends HttpServerTest { } @Override - String expectedServerSpanName(String method, ServerEndpoint endpoint) { + String expectedServerSpanName(ServerEndpoint endpoint) { return "netty.request" } diff --git a/instrumentation/netty/netty-3.8/src/test/groovy/Netty38ServerTest.groovy b/instrumentation/netty/netty-3.8/src/test/groovy/Netty38ServerTest.groovy index f717a9ed35..bb77939728 100644 --- a/instrumentation/netty/netty-3.8/src/test/groovy/Netty38ServerTest.groovy +++ b/instrumentation/netty/netty-3.8/src/test/groovy/Netty38ServerTest.groovy @@ -141,7 +141,7 @@ class Netty38ServerTest extends HttpServerTest { } @Override - String expectedServerSpanName(String method, ServerEndpoint endpoint) { + String expectedServerSpanName(ServerEndpoint endpoint) { return "netty.request" } diff --git a/instrumentation/netty/netty-4.0/src/test/groovy/Netty40ServerTest.groovy b/instrumentation/netty/netty-4.0/src/test/groovy/Netty40ServerTest.groovy index 3925310038..488b4d12fe 100644 --- a/instrumentation/netty/netty-4.0/src/test/groovy/Netty40ServerTest.groovy +++ b/instrumentation/netty/netty-4.0/src/test/groovy/Netty40ServerTest.groovy @@ -113,7 +113,7 @@ class Netty40ServerTest extends HttpServerTest { } @Override - String expectedServerSpanName(String method, ServerEndpoint endpoint) { + String expectedServerSpanName(ServerEndpoint endpoint) { return "netty.request" } diff --git a/instrumentation/netty/netty-4.1/src/test/groovy/Netty41ServerTest.groovy b/instrumentation/netty/netty-4.1/src/test/groovy/Netty41ServerTest.groovy index 3009cdf6f5..78f7b984ab 100644 --- a/instrumentation/netty/netty-4.1/src/test/groovy/Netty41ServerTest.groovy +++ b/instrumentation/netty/netty-4.1/src/test/groovy/Netty41ServerTest.groovy @@ -112,7 +112,7 @@ class Netty41ServerTest extends HttpServerTest { } @Override - String expectedServerSpanName(String method, ServerEndpoint endpoint) { + String expectedServerSpanName(ServerEndpoint endpoint) { return "netty.request" } diff --git a/instrumentation/play/play-2.3/src/test/groovy/server/PlayServerTest.groovy b/instrumentation/play/play-2.3/src/test/groovy/server/PlayServerTest.groovy index c3a4392e11..53ff01ede7 100644 --- a/instrumentation/play/play-2.3/src/test/groovy/server/PlayServerTest.groovy +++ b/instrumentation/play/play-2.3/src/test/groovy/server/PlayServerTest.groovy @@ -46,7 +46,7 @@ class PlayServerTest extends HttpServerTest { } @Override - String expectedServerSpanName(String method, ServerEndpoint endpoint) { + String expectedServerSpanName(ServerEndpoint endpoint) { return "netty.request" } } diff --git a/instrumentation/play/play-2.4/src/test/groovy/server/PlayServerTest.groovy b/instrumentation/play/play-2.4/src/test/groovy/server/PlayServerTest.groovy index e62eaa9202..59c87cd856 100644 --- a/instrumentation/play/play-2.4/src/test/groovy/server/PlayServerTest.groovy +++ b/instrumentation/play/play-2.4/src/test/groovy/server/PlayServerTest.groovy @@ -83,7 +83,7 @@ class PlayServerTest extends HttpServerTest { } @Override - String expectedServerSpanName(String method, ServerEndpoint endpoint) { + String expectedServerSpanName(ServerEndpoint endpoint) { return "netty.request" } diff --git a/instrumentation/play/play-2.6/src/test/groovy/server/PlayServerTest.groovy b/instrumentation/play/play-2.6/src/test/groovy/server/PlayServerTest.groovy index 12b1782109..f90f08d8ea 100644 --- a/instrumentation/play/play-2.6/src/test/groovy/server/PlayServerTest.groovy +++ b/instrumentation/play/play-2.6/src/test/groovy/server/PlayServerTest.groovy @@ -85,7 +85,7 @@ class PlayServerTest extends HttpServerTest { } @Override - String expectedServerSpanName(String method, ServerEndpoint endpoint) { + String expectedServerSpanName(ServerEndpoint endpoint) { return "akka.request" } diff --git a/instrumentation/ratpack-1.4/src/test/groovy/server/RatpackHttpServerTest.groovy b/instrumentation/ratpack-1.4/src/test/groovy/server/RatpackHttpServerTest.groovy index de5ab2ca51..4756ebb01d 100644 --- a/instrumentation/ratpack-1.4/src/test/groovy/server/RatpackHttpServerTest.groovy +++ b/instrumentation/ratpack-1.4/src/test/groovy/server/RatpackHttpServerTest.groovy @@ -120,7 +120,7 @@ class RatpackHttpServerTest extends HttpServerTest { } @Override - String expectedServerSpanName(String method, ServerEndpoint endpoint) { + String expectedServerSpanName(ServerEndpoint endpoint) { return endpoint.status == 404 ? "/" : endpoint == PATH_PARAM ? "/path/:id/param" : endpoint.path } } diff --git a/instrumentation/servlet/glassfish-testing/src/test/groovy/GlassFishServerTest.groovy b/instrumentation/servlet/glassfish-testing/src/test/groovy/GlassFishServerTest.groovy index b3b38db668..2ff1b6fe0f 100644 --- a/instrumentation/servlet/glassfish-testing/src/test/groovy/GlassFishServerTest.groovy +++ b/instrumentation/servlet/glassfish-testing/src/test/groovy/GlassFishServerTest.groovy @@ -3,13 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION -import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS -import static io.opentelemetry.trace.Span.Kind.SERVER - -import io.opentelemetry.instrumentation.test.asserts.TraceAssert import io.opentelemetry.instrumentation.test.base.HttpServerTest -import io.opentelemetry.trace.attributes.SemanticAttributes import org.glassfish.embeddable.BootstrapProperties import org.glassfish.embeddable.Deployer import org.glassfish.embeddable.GlassFish @@ -69,39 +63,11 @@ class GlassFishServerTest extends HttpServerTest { true } + // Simple class name plus method name of the entry point of the given servlet container. + // "Entry point" here means the first filter or servlet that accepts incoming requests. + // This will serve as a default name of the SERVER span created for this request. @Override - void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) { - trace.span(index) { - name entryPointName() - kind SERVER - errored endpoint.errored - if (parentID != null) { - traceId traceID - parentSpanId parentID - } else { - hasNoParent() - } - if (endpoint == EXCEPTION) { - errorEvent(Exception, EXCEPTION.body) - } - attributes { - "${SemanticAttributes.NET_PEER_IP.key()}" "127.0.0.1" - "${SemanticAttributes.NET_PEER_PORT.key()}" Long - "${SemanticAttributes.HTTP_STATUS_CODE.key()}" endpoint.status - "${SemanticAttributes.HTTP_METHOD.key()}" method - "${SemanticAttributes.HTTP_URL.key()}" { it == "${endpoint.resolve(address)}" || it == "${endpoint.resolveWithoutFragment(address)}" } - "${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1" - "${SemanticAttributes.HTTP_USER_AGENT.key()}" TEST_USER_AGENT - "${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP - } - } - } - - //Simple class name plus method name of the entry point of the given servlet container. - //"Entry point" here means the first filter or servlet that accepts incoming requests. - //This will serve as a default name of the SERVER span created for this request. - protected String entryPointName() { - 'HttpServlet.service' + String expectedServerSpanName(ServerEndpoint endpoint) { + "HttpServlet.service" } } - diff --git a/instrumentation/servlet/servlet-2.2/src/test/groovy/JettyServlet2Test.groovy b/instrumentation/servlet/servlet-2.2/src/test/groovy/JettyServlet2Test.groovy index 2984692861..34eb57a56c 100644 --- a/instrumentation/servlet/servlet-2.2/src/test/groovy/JettyServlet2Test.groovy +++ b/instrumentation/servlet/servlet-2.2/src/test/groovy/JettyServlet2Test.groovy @@ -10,12 +10,10 @@ import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEn import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.REDIRECT import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS import static io.opentelemetry.trace.Span.Kind.INTERNAL -import static io.opentelemetry.trace.Span.Kind.SERVER import io.opentelemetry.instrumentation.test.asserts.TraceAssert import io.opentelemetry.instrumentation.test.base.HttpServerTest import io.opentelemetry.sdk.trace.data.SpanData -import io.opentelemetry.trace.attributes.SemanticAttributes import javax.servlet.http.HttpServletRequest import org.eclipse.jetty.server.Server import org.eclipse.jetty.server.handler.ErrorHandler @@ -84,32 +82,9 @@ class JettyServlet2Test extends HttpServerTest { } } - // 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) { - trace.span(index) { - name 'HttpServlet.service' - kind SERVER - errored endpoint.errored - if (parentID != null) { - traceId traceID - parentSpanId parentID - } else { - hasNoParent() - } - if (endpoint == EXCEPTION) { - errorEvent(Exception, EXCEPTION.body) - } - attributes { - "${SemanticAttributes.NET_PEER_IP.key()}" "127.0.0.1" - // No peer port - "${SemanticAttributes.HTTP_URL.key()}" { it == "${endpoint.resolve(address)}" || it == "${endpoint.resolveWithoutFragment(address)}" } - "${SemanticAttributes.HTTP_METHOD.key()}" method - "${SemanticAttributes.HTTP_STATUS_CODE.key()}" endpoint.status - "${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1" - "${SemanticAttributes.HTTP_USER_AGENT.key()}" TEST_USER_AGENT - "${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP - } - } + @Override + String expectedServerSpanName(ServerEndpoint endpoint) { + "HttpServlet.service" } /** diff --git a/instrumentation/servlet/servlet-3.0/src/test/groovy/AbstractServlet3Test.groovy b/instrumentation/servlet/servlet-3.0/src/test/groovy/AbstractServlet3Test.groovy index 509a176462..09d8e6baf2 100644 --- a/instrumentation/servlet/servlet-3.0/src/test/groovy/AbstractServlet3Test.groovy +++ b/instrumentation/servlet/servlet-3.0/src/test/groovy/AbstractServlet3Test.groovy @@ -10,10 +10,7 @@ import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEn import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.REDIRECT import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS -import io.opentelemetry.instrumentation.test.asserts.TraceAssert import io.opentelemetry.instrumentation.test.base.HttpServerTest -import io.opentelemetry.trace.Span -import io.opentelemetry.trace.attributes.SemanticAttributes import javax.servlet.Servlet import okhttp3.Request import okhttp3.RequestBody @@ -57,38 +54,11 @@ abstract class AbstractServlet3Test extends HttpServerTest } @Override - protected String entryPointName() { + String expectedServerSpanName(ServerEndpoint endpoint) { return 'ApplicationFilterChain.doFilter' } 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 d06b045767..4d15a5d1c5 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 @@ -159,6 +159,8 @@ class SpringBootBasedTest extends HttpServerTest } } + // this override is needed because the exception is propagated up from the handler span + // to the server span, which is different from the the expectation of the super method @Override void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) { 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 a2437412ad..843e29099c 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 @@ -10,13 +10,11 @@ import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEn import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.PATH_PARAM import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS import static io.opentelemetry.trace.Span.Kind.INTERNAL -import static io.opentelemetry.trace.Span.Kind.SERVER import com.google.common.collect.ImmutableMap import io.opentelemetry.instrumentation.test.asserts.TraceAssert import io.opentelemetry.instrumentation.test.base.HttpServerTest import io.opentelemetry.sdk.trace.data.SpanData -import io.opentelemetry.trace.attributes.SemanticAttributes import org.springframework.boot.SpringApplication import org.springframework.context.ConfigurableApplicationContext import test.boot.SecurityConfig @@ -77,31 +75,8 @@ class ServletFilterTest extends HttpServerTest { } @Override - void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) { - trace.span(index) { - name endpoint == PATH_PARAM ? "/path/{id}/param" : endpoint.resolvePath(address).path - kind SERVER - errored endpoint.errored - if (parentID != null) { - traceId traceID - parentSpanId parentID - } else { - hasNoParent() - } - if (endpoint == EXCEPTION) { - errorEvent(Exception, EXCEPTION.body) - } - attributes { - "${SemanticAttributes.NET_PEER_IP.key()}" { it == null || it == "127.0.0.1" } // Optional - "${SemanticAttributes.NET_PEER_PORT.key()}" Long - "${SemanticAttributes.HTTP_URL.key()}" { it == "${endpoint.resolve(address)}" || it == "${endpoint.resolveWithoutFragment(address)}" } - "${SemanticAttributes.HTTP_METHOD.key()}" method - "${SemanticAttributes.HTTP_STATUS_CODE.key()}" endpoint.status - "${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1" - "${SemanticAttributes.HTTP_USER_AGENT.key()}" TEST_USER_AGENT - "${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP - } - } + String expectedServerSpanName(ServerEndpoint endpoint) { + return endpoint == PATH_PARAM ? "/path/{id}/param" : endpoint.resolvePath(address).path } @Override diff --git a/instrumentation/vertx-3.0/src/test/groovy/server/VertxHttpServerTest.groovy b/instrumentation/vertx-3.0/src/test/groovy/server/VertxHttpServerTest.groovy index 43ee67a475..c5024adde3 100644 --- a/instrumentation/vertx-3.0/src/test/groovy/server/VertxHttpServerTest.groovy +++ b/instrumentation/vertx-3.0/src/test/groovy/server/VertxHttpServerTest.groovy @@ -71,7 +71,7 @@ class VertxHttpServerTest extends HttpServerTest { } @Override - String expectedServerSpanName(String method, ServerEndpoint endpoint) { + String expectedServerSpanName(ServerEndpoint endpoint) { return endpoint == PATH_PARAM ? "/path/:id/param" : endpoint.getPath() } diff --git a/instrumentation/vertx-reactive-3.5/src/test/groovy/server/VertxRxHttpServerTest.groovy b/instrumentation/vertx-reactive-3.5/src/test/groovy/server/VertxRxHttpServerTest.groovy index fbae448e3e..e92df5d2d9 100644 --- a/instrumentation/vertx-reactive-3.5/src/test/groovy/server/VertxRxHttpServerTest.groovy +++ b/instrumentation/vertx-reactive-3.5/src/test/groovy/server/VertxRxHttpServerTest.groovy @@ -74,7 +74,7 @@ class VertxRxHttpServerTest extends HttpServerTest { } @Override - String expectedServerSpanName(String method, ServerEndpoint endpoint) { + String expectedServerSpanName(ServerEndpoint endpoint) { return endpoint == PATH_PARAM ? "/path/:id/param" : endpoint.getPath() } 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 3f298f078b..8778190d20 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 @@ -84,7 +84,7 @@ abstract class HttpServerTest extends AgentTestRunner { abstract void stopServer(SERVER server) - String expectedServerSpanName(String method, ServerEndpoint endpoint) { + String expectedServerSpanName(ServerEndpoint endpoint) { return endpoint == PATH_PARAM ? "/path/:id/param" : endpoint.resolvePath(address).path } @@ -442,7 +442,7 @@ abstract class HttpServerTest extends AgentTestRunner { // 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) { trace.span(index) { - name expectedServerSpanName(method, endpoint) + name expectedServerSpanName(endpoint) kind Span.Kind.SERVER // can't use static import because of SERVER type parameter errored endpoint.errored if (parentID != null) {