From 059a4cac900c368e820a20b823691e029eb66932 Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Tue, 19 Nov 2024 17:54:27 +0200 Subject: [PATCH] Convert jaxrs-1.0 tests to java (#12745) --- .../jaxrs-1.0/javaagent/build.gradle.kts | 15 +- .../jaxrs/v1_0/JaxrsSingletons.java | 5 - ...axRsAnnotations1InstrumentationTest.groovy | 168 ----------------- .../src/test/groovy/JerseyTest.groovy | 107 ----------- .../jaxrs/v1_0}/JavaInterfaces.java | 2 + .../JaxRsAnnotations1InstrumentationTest.java | 174 ++++++++++++++++++ .../jaxrs/v1_0/JerseyTest.java | 127 +++++++++++++ .../instrumentation/jaxrs/v1_0}/Resource.java | 3 +- 8 files changed, 316 insertions(+), 285 deletions(-) delete mode 100644 instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/groovy/JaxRsAnnotations1InstrumentationTest.groovy delete mode 100644 instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/groovy/JerseyTest.groovy rename instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/{ => io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0}/JavaInterfaces.java (94%) create mode 100644 instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0/JaxRsAnnotations1InstrumentationTest.java create mode 100644 instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0/JerseyTest.java rename instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/{ => io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0}/Resource.java (93%) diff --git a/instrumentation/jaxrs/jaxrs-1.0/javaagent/build.gradle.kts b/instrumentation/jaxrs/jaxrs-1.0/javaagent/build.gradle.kts index 1b0f3e6ecceb..918062a20b02 100644 --- a/instrumentation/jaxrs/jaxrs-1.0/javaagent/build.gradle.kts +++ b/instrumentation/jaxrs/jaxrs-1.0/javaagent/build.gradle.kts @@ -20,12 +20,19 @@ dependencies { compileOnly("javax.ws.rs:jsr311-api:1.1.1") - // Jackson, used by the test, dropped support for jax 1.x in 2.13+ - testImplementation(enforcedPlatform("com.fasterxml.jackson:jackson-bom:2.12.6")) - testImplementation("io.dropwizard:dropwizard-testing:0.7.1") - testImplementation("javax.xml.bind:jaxb-api:2.2.3") + testInstrumentation(project(":instrumentation:jetty:jetty-8.0:javaagent")) + + testImplementation("org.eclipse.jetty:jetty-webapp:9.4.6.v20170531") + testImplementation("com.sun.jersey:jersey-servlet:1.19.4") + testImplementation("javax.xml.bind:jaxb-api:2.2.11") + testImplementation("com.sun.xml.bind:jaxb-core:2.2.11") + testImplementation("com.sun.xml.bind:jaxb-impl:2.2.11") + testImplementation("javax.activation:activation:1.1.1") } tasks.withType().configureEach { jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") + // required on jdk17 + jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") + jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") } diff --git a/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0/JaxrsSingletons.java b/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0/JaxrsSingletons.java index ea59c1902366..8a4bc94451be 100644 --- a/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0/JaxrsSingletons.java +++ b/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0/JaxrsSingletons.java @@ -13,11 +13,6 @@ public final class JaxrsSingletons { - public static final String ABORT_FILTER_CLASS = - "io.opentelemetry.javaagent.instrumentation.jaxrs2.filter.abort.class"; - public static final String ABORT_HANDLED = - "io.opentelemetry.javaagent.instrumentation.jaxrs2.filter.abort.handled"; - private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jaxrs-1.0"; private static final Instrumenter INSTRUMENTER; diff --git a/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/groovy/JaxRsAnnotations1InstrumentationTest.groovy b/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/groovy/JaxRsAnnotations1InstrumentationTest.groovy deleted file mode 100644 index 375cb13cdfdf..000000000000 --- a/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/groovy/JaxRsAnnotations1InstrumentationTest.groovy +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification -import io.opentelemetry.semconv.incubating.CodeIncubatingAttributes -import io.opentelemetry.semconv.ErrorAttributes -import io.opentelemetry.semconv.HttpAttributes -import spock.lang.Unroll - -import javax.ws.rs.DELETE -import javax.ws.rs.GET -import javax.ws.rs.HEAD -import javax.ws.rs.OPTIONS -import javax.ws.rs.POST -import javax.ws.rs.PUT -import javax.ws.rs.Path - -import static io.opentelemetry.api.trace.SpanKind.SERVER -import static io.opentelemetry.instrumentation.test.utils.ClassUtils.getClassName - -class JaxRsAnnotations1InstrumentationTest extends AgentInstrumentationSpecification { - - @Unroll - def "span named '#paramName' from annotations on class '#className' when is not root span"() { - setup: - runWithHttpServerSpan { - obj.call() - } - - expect: - assertTraces(1) { - trace(0, 2) { - span(0) { - name "GET " + paramName - kind SERVER - hasNoParent() - attributes { - "$HttpAttributes.HTTP_REQUEST_METHOD" "GET" - "$HttpAttributes.HTTP_ROUTE" paramName - "$ErrorAttributes.ERROR_TYPE" "_OTHER" - } - } - span(1) { - name "${className}.call" - childOf span(0) - attributes { - "$CodeIncubatingAttributes.CODE_NAMESPACE" obj.getClass().getName() - "$CodeIncubatingAttributes.CODE_FUNCTION" "call" - } - } - } - } - - when: "multiple calls to the same method" - runWithHttpServerSpan { - (1..10).each { - obj.call() - } - } - then: "doesn't increase the cache size" - - where: - paramName | obj - "/a" | new Jax() { - @Path("/a") - void call() { - } - } - "/b" | new Jax() { - @GET - @Path("/b") - void call() { - } - } - "/interface/c" | new InterfaceWithPath() { - @POST - @Path("/c") - void call() { - } - } - "/interface" | new InterfaceWithPath() { - @HEAD - void call() { - } - } - "/abstract/d" | new AbstractClassWithPath() { - @POST - @Path("/d") - void call() { - } - } - "/abstract" | new AbstractClassWithPath() { - @PUT - void call() { - } - } - "/child/e" | new ChildClassWithPath() { - @OPTIONS - @Path("/e") - void call() { - } - } - "/child/call" | new ChildClassWithPath() { - @DELETE - void call() { - } - } - "/child/call" | new ChildClassWithPath() - "/child/call" | new JavaInterfaces.ChildClassOnInterface() - "/child/call" | new JavaInterfaces.DefaultChildClassOnInterface() - - className = getClassName(obj.class) - } - - def "no annotations has no effect"() { - setup: - runWithHttpServerSpan { - obj.call() - } - - expect: - assertTraces(1) { - trace(0, 1) { - span(0) { - name "GET" - kind SERVER - attributes { - "$HttpAttributes.HTTP_REQUEST_METHOD" "GET" - "$ErrorAttributes.ERROR_TYPE" "_OTHER" - } - } - } - } - - where: - obj | _ - new Jax() { - void call() { - } - } | _ - } - - interface Jax { - void call() - } - - @Path("/interface") - interface InterfaceWithPath extends Jax { - @GET - void call() - } - - @Path("/abstract") - static abstract class AbstractClassWithPath implements Jax { - @PUT - abstract void call() - } - - @Path("child") - static class ChildClassWithPath extends AbstractClassWithPath { - @Path("call") - @POST - void call() { - } - } -} diff --git a/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/groovy/JerseyTest.groovy b/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/groovy/JerseyTest.groovy deleted file mode 100644 index 57305fd90486..000000000000 --- a/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/groovy/JerseyTest.groovy +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -import io.dropwizard.testing.junit.ResourceTestRule -import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification -import io.opentelemetry.semconv.incubating.CodeIncubatingAttributes -import io.opentelemetry.semconv.ErrorAttributes -import io.opentelemetry.semconv.HttpAttributes -import org.junit.ClassRule -import spock.lang.Shared -import spock.lang.Unroll - -import static io.opentelemetry.api.trace.SpanKind.INTERNAL -import static io.opentelemetry.api.trace.SpanKind.SERVER - -class JerseyTest extends AgentInstrumentationSpecification { - - @Shared - @ClassRule - ResourceTestRule resources = ResourceTestRule.builder() - .addResource(new Resource.Test1()) - .addResource(new Resource.Test2()) - .addResource(new Resource.Test3()) - .build() - - @Unroll - def "test #resource"() { - when: - // start a trace because the test doesn't go through any servlet or other instrumentation. - def response = runWithHttpServerSpan { - resources.client().resource(resource).post(String) - } - - then: - response == expectedResponse - - assertTraces(1) { - trace(0, 2) { - span(0) { - name "GET " + expectedRoute - kind SERVER - attributes { - "$HttpAttributes.HTTP_REQUEST_METHOD" "GET" - "$HttpAttributes.HTTP_ROUTE" expectedRoute - "$ErrorAttributes.ERROR_TYPE" "_OTHER" - } - } - - span(1) { - childOf span(0) - name controllerName - attributes { - "$CodeIncubatingAttributes.CODE_NAMESPACE" ~/Resource[$]Test*/ - "$CodeIncubatingAttributes.CODE_FUNCTION" "hello" - } - } - } - } - - where: - resource | expectedRoute | controllerName | expectedResponse - "/test/hello/bob" | "/test/hello/{name}" | "Test1.hello" | "Test1 bob!" - "/test2/hello/bob" | "/test2/hello/{name}" | "Test2.hello" | "Test2 bob!" - "/test3/hi/bob" | "/test3/hi/{name}" | "Test3.hello" | "Test3 bob!" - } - - def "test nested call"() { - - when: - // start a trace because the test doesn't go through any servlet or other instrumentation. - def response = runWithHttpServerSpan { - resources.client().resource(resource).post(String) - } - - then: - response == expectedResponse - - assertTraces(1) { - trace(0, 2) { - span(0) { - name "GET " + expectedRoute - kind SERVER - attributes { - "$HttpAttributes.HTTP_REQUEST_METHOD" "GET" - "$HttpAttributes.HTTP_ROUTE" expectedRoute - "$ErrorAttributes.ERROR_TYPE" "_OTHER" - } - } - span(1) { - childOf span(0) - name controller1Name - kind INTERNAL - attributes { - "$CodeIncubatingAttributes.CODE_NAMESPACE" ~/Resource[$]Test*/ - "$CodeIncubatingAttributes.CODE_FUNCTION" "nested" - } - } - } - } - - where: - resource | expectedRoute | controller1Name | expectedResponse - "/test3/nested" | "/test3/nested" | "Test3.nested" | "Test3 nested!" - } -} diff --git a/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/JavaInterfaces.java b/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0/JavaInterfaces.java similarity index 94% rename from instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/JavaInterfaces.java rename to instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0/JavaInterfaces.java index bcd5e76cc11d..9d283aa2c258 100644 --- a/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/JavaInterfaces.java +++ b/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0/JavaInterfaces.java @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +package io.opentelemetry.javaagent.instrumentation.jaxrs.v1_0; + import javax.ws.rs.GET; import javax.ws.rs.Path; diff --git a/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0/JaxRsAnnotations1InstrumentationTest.java b/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0/JaxRsAnnotations1InstrumentationTest.java new file mode 100644 index 000000000000..2cd0de942cfd --- /dev/null +++ b/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0/JaxRsAnnotations1InstrumentationTest.java @@ -0,0 +1,174 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.javaagent.instrumentation.jaxrs.v1_0; + +import static io.opentelemetry.instrumentation.test.utils.ClassUtils.getClassName; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; +import static io.opentelemetry.semconv.ErrorAttributes.ERROR_TYPE; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_REQUEST_METHOD; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_ROUTE; +import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_FUNCTION; +import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_NAMESPACE; + +import io.opentelemetry.api.trace.SpanKind; +import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; +import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; +import io.opentelemetry.javaagent.instrumentation.jaxrs.v1_0.JavaInterfaces.Jax; +import io.opentelemetry.semconv.ErrorAttributes; +import java.util.stream.Stream; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.OPTIONS; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +class JaxRsAnnotations1InstrumentationTest { + + @RegisterExtension + static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); + + private static Stream provideArguments() { + return Stream.of( + Arguments.of( + "/a", + new Jax() { + @Path("/a") + @Override + public void call() {} + }), + Arguments.of( + "/b", + new Jax() { + @GET + @Path("/b") + @Override + public void call() {} + }), + Arguments.of( + "/interface/c", + new InterfaceWithPath() { + @POST + @Path("/c") + @Override + public void call() {} + }), + Arguments.of( + "/interface", + new InterfaceWithPath() { + @HEAD + @Override + public void call() {} + }), + Arguments.of( + "/abstract/d", + new AbstractClassWithPath() { + @POST + @Path("/d") + @Override + public void call() {} + }), + Arguments.of( + "/abstract", + new AbstractClassWithPath() { + @PUT + @Override + public void call() {} + }), + Arguments.of( + "/child/e", + new ChildClassWithPath() { + @OPTIONS + @Path("/e") + @Override + public void call() {} + }), + Arguments.of( + "/child/call", + new ChildClassWithPath() { + @DELETE + @Override + public void call() {} + }), + Arguments.of("/child/call", new ChildClassWithPath()), + Arguments.of("/child/call", new JavaInterfaces.ChildClassOnInterface()), + Arguments.of("/child/call", new JavaInterfaces.DefaultChildClassOnInterface())); + } + + @ParameterizedTest + @MethodSource("provideArguments") + void createSpanForAnnotatedMethod(String path, Jax action) { + String className = getClassName(action.getClass()); + testing.runWithHttpServerSpan(action::call); + + testing.waitAndAssertTraces( + trace -> + trace.hasSpansSatisfyingExactly( + span -> + span.hasName("GET " + path) + .hasKind(SpanKind.SERVER) + .hasNoParent() + .hasAttributesSatisfyingExactly( + equalTo(HTTP_REQUEST_METHOD, "GET"), + equalTo(HTTP_ROUTE, path), + equalTo(ERROR_TYPE, ErrorAttributes.ErrorTypeValues.OTHER)), + span -> + span.hasName(className + ".call") + .hasParent(trace.getSpan(0)) + .hasAttributesSatisfyingExactly( + equalTo(CODE_NAMESPACE, action.getClass().getName()), + equalTo(CODE_FUNCTION, "call")))); + } + + @Test + void notAnnotatedMethod() { + Jax action = + new Jax() { + @Override + public void call() {} + }; + testing.runWithHttpServerSpan(action::call); + + testing.waitAndAssertTraces( + trace -> + trace.hasSpansSatisfyingExactly( + span -> + span.hasName("GET") + .hasKind(SpanKind.SERVER) + .hasNoParent() + .hasAttributesSatisfyingExactly( + equalTo(HTTP_REQUEST_METHOD, "GET"), + equalTo(ERROR_TYPE, ErrorAttributes.ErrorTypeValues.OTHER)))); + } + + @Path("/interface") + interface InterfaceWithPath extends Jax { + @GET + @Override + void call(); + } + + @Path("/abstract") + abstract static class AbstractClassWithPath implements Jax { + @PUT + @Override + public abstract void call(); + } + + @Path("child") + static class ChildClassWithPath extends AbstractClassWithPath { + @Path("call") + @POST + @Override + public void call() {} + } +} diff --git a/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0/JerseyTest.java b/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0/JerseyTest.java new file mode 100644 index 000000000000..ea40e171482c --- /dev/null +++ b/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0/JerseyTest.java @@ -0,0 +1,127 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.javaagent.instrumentation.jaxrs.v1_0; + +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_REQUEST_METHOD; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_ROUTE; +import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_FUNCTION; +import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_NAMESPACE; +import static org.assertj.core.api.Assertions.assertThat; + +import com.sun.jersey.spi.container.servlet.ServletContainer; +import io.opentelemetry.api.trace.SpanKind; +import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; +import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerUsingTest; +import io.opentelemetry.instrumentation.testing.junit.http.HttpServerInstrumentationExtension; +import io.opentelemetry.testing.internal.armeria.common.AggregatedHttpResponse; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Stream; +import javax.ws.rs.core.Application; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +class JerseyTest extends AbstractHttpServerUsingTest { + + @RegisterExtension + public static final InstrumentationExtension testing = + HttpServerInstrumentationExtension.forAgent(); + + @BeforeAll + protected void setUp() { + startServer(); + } + + @AfterAll + protected void cleanUp() { + cleanupServer(); + } + + @Override + protected Server setupServer() throws Exception { + ServletContainer servlet = + new ServletContainer( + new Application() { + @Override + public Set getSingletons() { + Set objects = new HashSet<>(); + objects.add(new Resource.Test1()); + objects.add(new Resource.Test2()); + objects.add(new Resource.Test3()); + return objects; + } + }); + + ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.SESSIONS); + handler.setContextPath(getContextPath()); + handler.addServlet(new ServletHolder(servlet), "/*"); + + Server server = new Server(port); + server.setHandler(handler); + server.start(); + + return server; + } + + @Override + protected void stopServer(Server server) throws Exception { + server.stop(); + server.destroy(); + } + + @Override + protected String getContextPath() { + return "/jetty-context"; + } + + private static Stream provideArguments() { + return Stream.of( + Arguments.of("test/hello/bob", "/test/hello/{name}", "Test1", "hello", "Test1 bob!"), + Arguments.of("test2/hello/bob", "/test2/hello/{name}", "Test2", "hello", "Test2 bob!"), + Arguments.of("test3/hi/bob", "/test3/hi/{name}", "Test3", "hello", "Test3 bob!"), + Arguments.of("test3/nested", "/test3/nested", "Test3", "nested", "Test3 nested!")); + } + + @ParameterizedTest + @MethodSource("provideArguments") + void request( + String resource, + String expectedRoute, + String className, + String methodName, + String expectedResponse) { + AggregatedHttpResponse response = + client.post(address.resolve(resource).toString(), "bob").aggregate().join(); + assertThat(response.status().code()).isEqualTo(200); + assertThat(response.contentUtf8()).isEqualTo(expectedResponse); + + String controllerName = className + "." + methodName; + testing.waitAndAssertTraces( + trace -> + trace.hasSpansSatisfyingExactly( + span -> + span.hasName("POST " + getContextPath() + expectedRoute) + .hasKind(SpanKind.SERVER) + .hasNoParent() + .hasAttributesSatisfying( + equalTo(HTTP_REQUEST_METHOD, "POST"), + equalTo(HTTP_ROUTE, getContextPath() + expectedRoute)), + span -> + span.hasName(controllerName) + .hasParent(trace.getSpan(0)) + .hasAttributesSatisfyingExactly( + equalTo(CODE_NAMESPACE, Resource.class.getName() + "$" + className), + equalTo(CODE_FUNCTION, methodName)))); + } +} diff --git a/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/Resource.java b/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0/Resource.java similarity index 93% rename from instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/Resource.java rename to instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0/Resource.java index d962f172ca63..b9af00ff8096 100644 --- a/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/Resource.java +++ b/instrumentation/jaxrs/jaxrs-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v1_0/Resource.java @@ -3,11 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ +package io.opentelemetry.javaagent.instrumentation.jaxrs.v1_0; + import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; -// Originally had this as a groovy class but was getting some weird errors. @Path("/ignored") public interface Resource { @Path("ignored")