Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ abstract class AbstractHttpServerInstrumentationTest
)
// instrumentation does not create a span at all
options.disableTestNonStandardHttpMethod
options.setExpectedException(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just make the scala and grails tests also throw IllegalStateException. The only one tests that could keep using are the old groovy tests, they'll get converted eventually anyway.

new Exception(ServerEndpoint.EXCEPTION.getBody())
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected Server setupServer() {
.runWithSpan(
"controller",
() -> {
throw new Exception(EXCEPTION.getBody());
throw new IllegalStateException(EXCEPTION.getBody());
}));

sb.service(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class FinatraServerLatestTest extends AbstractHttpServerTest[HttpServer] {
endpoint != ServerEndpoint.NOT_FOUND
})
options.setResponseCodeOnNonStandardHttpMethod(400)
options.setExpectedException(
new Exception(ServerEndpoint.EXCEPTION.getBody())
)
}

override protected def assertHandlerSpan(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class FinatraServerTest extends AbstractHttpServerTest[HttpServer] {
endpoint != ServerEndpoint.NOT_FOUND
})
options.setResponseCodeOnNonStandardHttpMethod(400)
options.setExpectedException(
new Exception(ServerEndpoint.EXCEPTION.getBody())
)
}

override protected def assertHandlerSpan(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ protected void configure(HttpServerTestOptions options) {
endpoint -> endpoint == ERROR || endpoint == EXCEPTION || endpoint == NOT_FOUND);
options.setTestPathParam(true);
options.setResponseCodeOnNonStandardHttpMethod(testLatestDeps ? 200 : 501);
options.setExpectedException(new Exception(EXCEPTION.getBody()));
}

@SpringBootApplication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ protected void configure(HttpServerTestOptions options) {
Sets.difference(
DEFAULT_HTTP_ATTRIBUTES, Collections.singleton(HttpAttributes.HTTP_ROUTE)));
options.setHasResponseSpan(endpoint -> endpoint == REDIRECT || endpoint == ERROR);
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
options.setHasResponseCustomizer(endpoint -> true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ protected void configure(HttpServerTestOptions options) {
unused ->
Sets.difference(
DEFAULT_HTTP_ATTRIBUTES, Collections.singleton(HttpAttributes.HTTP_ROUTE)));
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
options.setHasResponseCustomizer(endpoint -> endpoint != EXCEPTION);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ protected void configure(HttpServerTestOptions options) {
Sets.difference(
DEFAULT_HTTP_ATTRIBUTES, Collections.singleton(HttpAttributes.HTTP_ROUTE)));
options.setHasResponseSpan(endpoint -> endpoint == REDIRECT || endpoint == ERROR);
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
options.setHasResponseCustomizer(endpoint -> endpoint != EXCEPTION);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class KtorHttpServerTest : AbstractHttpServerTest<ApplicationEngine>() {

get(ServerEndpoint.EXCEPTION.path) {
controller(ServerEndpoint.EXCEPTION) {
throw Exception(ServerEndpoint.EXCEPTION.body)
throw IllegalStateException(ServerEndpoint.EXCEPTION.body)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ abstract class AbstractKtorHttpServerTest : AbstractHttpServerTest<ApplicationEn

get(ServerEndpoint.EXCEPTION.path) {
controller(ServerEndpoint.EXCEPTION) {
throw Exception(ServerEndpoint.EXCEPTION.body)
throw IllegalStateException(ServerEndpoint.EXCEPTION.body)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ package io.opentelemetry.javaagent.instrumentation.pekkohttp.v1_0
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension
import io.opentelemetry.instrumentation.testing.junit.http.{
HttpServerInstrumentationExtension,
HttpServerTestOptions
HttpServerTestOptions,
ServerEndpoint
}
import org.junit.jupiter.api.extension.RegisterExtension

Expand All @@ -31,5 +32,8 @@ class PekkoHttpServerInstrumentationTestAsync
): Unit = {
super.configure(options)
options.setTestHttpPipelining(false)
options.setExpectedException(
new Exception(ServerEndpoint.EXCEPTION.getBody())
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ package io.opentelemetry.javaagent.instrumentation.pekkohttp.v1_0

import io.opentelemetry.instrumentation.testing.junit.http.{
HttpServerInstrumentationExtension,
HttpServerTestOptions
HttpServerTestOptions,
ServerEndpoint
}
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension
import org.junit.jupiter.api.extension.RegisterExtension
Expand All @@ -32,5 +33,8 @@ class PekkoHttpServerInstrumentationTestSync
super.configure(options)
// FIXME: latest deps does not fill http.status_code
options.setTestException(!java.lang.Boolean.getBoolean("testLatestDeps"))
options.setExpectedException(
new Exception(ServerEndpoint.EXCEPTION.getBody())
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ protected void configure(HttpServerTestOptions options) {
options.setTestPathParam(true);
options.setTestErrorBody(false);
options.setTestHttpPipelining(false);
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
options.setExpectedHttpRoute(
(endpoint, method) -> {
if (HttpConstants._OTHER.equals(method)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ protected void configure(HttpServerTestOptions options) {
super.configure(options);
options.setTestPathParam(true);
options.setTestErrorBody(false);
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
options.setExpectedHttpRoute(
(endpoint, method) -> {
if (HttpConstants._OTHER.equals(method)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ protected void configure(HttpServerTestOptions options) {
options.setTestCaptureHttpHeaders(false);
options.setHasResponseSpan(e -> e.equals(REDIRECT) || e.equals(ERROR));
options.setHasResponseCustomizer(e -> true);
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ protected void configure(HttpServerTestOptions options) {
options.setTestCaptureRequestParameters(true);
options.setHasResponseCustomizer(e -> true);
options.setHasResponseSpan(this::hasResponseSpan);
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
}

protected boolean hasResponseSpan(ServerEndpoint endpoint) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public static boolean isBefore94() {
protected void configure(HttpServerTestOptions options) {
super.configure(options);
options.setTestNotFound(false);
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
options.setContextPath("/jetty-context");
options.setVerifyServerSpanEndTime(!isAsyncTest());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ protected void configure(HttpServerTestOptions options) {
super.configure(options);
options.setContextPath("");
options.setTestNotFound(false);
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
options.setHttpAttributes(
serverEndpoint -> {
Set<AttributeKey<?>> attributes =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package io.opentelemetry.javaagent.instrumentation.servlet.v3_0.tomcat;

import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.ERROR;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.NOT_FOUND;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.SUCCESS;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -71,7 +70,6 @@ public abstract class TomcatServlet3Test extends AbstractServlet3Test<Tomcat, Co
@Override
protected void configure(HttpServerTestOptions options) {
super.configure(options);
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
options.setContextPath("/tomcat-context");
options.setTestError(testError());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

package io.opentelemetry.javaagent.instrumentation.servlet.v5_0.jetty;

import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION;

import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerInstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions;
Expand All @@ -32,7 +30,6 @@ public abstract class JettyServlet5Test
protected void configure(HttpServerTestOptions options) {
super.configure(options);
options.setTestNotFound(false);
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
options.setContextPath("/jetty-context");
}

Expand Down Expand Up @@ -67,8 +64,7 @@ public void stopServer(Server server) throws Exception {

@Override
public void addServlet(
ServletContextHandler servletContext, String path, Class<? extends Servlet> servlet)
throws Exception {
ServletContextHandler servletContext, String path, Class<? extends Servlet> servlet) {
servletContext.addServlet(servlet, path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

package io.opentelemetry.javaagent.instrumentation.servlet.v5_0.jetty;

import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerInstrumentationExtension;
Expand Down Expand Up @@ -36,7 +34,6 @@ protected void configure(HttpServerTestOptions options) {
super.configure(options);
options.setContextPath("");
options.setTestNotFound(false);
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
options.setHttpAttributes(
serverEndpoint -> {
Set<AttributeKey<?>> attributes =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

package io.opentelemetry.javaagent.instrumentation.servlet.v5_0.jetty12;

import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION;

import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerInstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions;
Expand All @@ -30,7 +28,6 @@ public abstract class Jetty12Servlet5Test
protected void configure(HttpServerTestOptions options) {
super.configure(options);
options.setTestNotFound(false);
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
options.setContextPath("/jetty-context");
}

Expand Down Expand Up @@ -64,8 +61,7 @@ public void stopServer(Server server) throws Exception {

@Override
public void addServlet(
ServletContextHandler servletContext, String path, Class<? extends Servlet> servlet)
throws Exception {
ServletContextHandler servletContext, String path, Class<? extends Servlet> servlet) {
servletContext.addServlet(servlet, path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ protected void configure(HttpServerTestOptions options) {
options.setTestCaptureRequestParameters(true);
options.setHasResponseCustomizer(e -> true);
options.setHasResponseSpan(this::hasResponseSpan);
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
}

protected boolean hasResponseSpan(ServerEndpoint endpoint) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package io.opentelemetry.javaagent.instrumentation.servlet.v5_0.tomcat;

import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.ERROR;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.NOT_FOUND;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.SUCCESS;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -71,7 +70,6 @@ public abstract class TomcatServlet5Test extends AbstractServlet5Test<Tomcat, Co
@Override
protected void configure(HttpServerTestOptions options) {
super.configure(options);
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
options.setContextPath("/tomcat-context");
options.setTestError(testError());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package io.opentelemetry.javaagent.instrumentation.spring.webflux.v5_0.server.base;

import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.NOT_FOUND;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.PATH_PARAM;

Expand Down Expand Up @@ -63,7 +62,6 @@ public String expectedHttpRoute(ServerEndpoint endpoint, String method) {
@Override
protected void configure(HttpServerTestOptions options) {
options.setTestPathParam(true);
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
options.setHasHandlerSpan(unused -> true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ protected void configure(HttpServerTestOptions options) {
options.setHasResponseSpan(
endpoint -> endpoint == REDIRECT || endpoint == ERROR || endpoint == NOT_FOUND);
options.setTestPathParam(true);
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ protected void configure(HttpServerTestOptions options) {
options.setTestPathParam(true);
options.setTestErrorBody(false);
options.setHasHandlerSpan(endpoint -> !endpoint.equals(NOT_FOUND));
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
options.setHasResponseSpan(
endpoint ->
endpoint == REDIRECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ protected void configure(HttpServerTestOptions options) {
return super.expectedHttpRoute(endpoint, method);
});

options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
options.setHasResponseSpan(endpoint -> endpoint == NOT_FOUND || endpoint == REDIRECT);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ protected void configure(HttpServerTestOptions options) {
options.setHasResponseCustomizer(serverEndpoint -> true);
options.setTestCaptureRequestParameters(true);
options.setTestErrorBody(false);
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));

options.setHasResponseSpan(
endpoint -> endpoint == REDIRECT || endpoint == ERROR || endpoint == NOT_FOUND);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ protected void configure(HttpServerTestOptions options) {
return super.expectedHttpRoute(endpoint, method);
});

options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
options.setHasResponseSpan(endpoint -> endpoint == NOT_FOUND || endpoint == REDIRECT);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ protected void configure(HttpServerTestOptions options) {
options.setHasResponseCustomizer(serverEndpoint -> true);
options.setTestCaptureRequestParameters(true);
options.setTestErrorBody(false);
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));

options.setHasResponseSpan(
endpoint -> endpoint == REDIRECT || endpoint == ERROR || endpoint == NOT_FOUND);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerTest;
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerInstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions;
import io.opentelemetry.instrumentation.testing.util.ThrowingRunnable;
import io.opentelemetry.semconv.ClientAttributes;
import io.opentelemetry.semconv.ExceptionAttributes;
import io.opentelemetry.semconv.HttpAttributes;
Expand Down Expand Up @@ -106,10 +105,9 @@ public Undertow setupServer() {
exchange ->
testing.runWithSpan(
"controller",
(ThrowingRunnable<Exception>)
() -> {
throw new Exception(EXCEPTION.getBody());
}))
() -> {
throw new IllegalStateException(EXCEPTION.getBody());
}))
.addExactPath(
INDEXED_CHILD.rawPath(),
exchange ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public abstract class AbstractHttpServerTest<SERVER> extends AbstractHttpServerU
void setupOptions() {
options.expectedServerSpanNameMapper = this::expectedServerSpanName;
options.expectedHttpRoute = this::expectedHttpRoute;
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason you didn't change this in

instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this when looking for where it was configured, i'll update


configure(options);

Expand Down
Loading