Skip to content

Commit a3788e7

Browse files
committed
more test stuff
1 parent 76b9b26 commit a3788e7

File tree

12 files changed

+431
-386
lines changed

12 files changed

+431
-386
lines changed

instrumentation/spring/spring-webflux/spring-webflux-5.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/v5_0/server/base/DelayedHandlerSpringWebFluxServerTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

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

8+
import io.opentelemetry.instrumentation.spring.webflux.server.AbstractHandlerSpringWebFluxServerTest;
89
import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint;
910
import java.time.Duration;
1011
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -20,7 +21,7 @@
2021
* map step, which follows a delay step. For exception endpoint, the exception is thrown within the
2122
* last map step.
2223
*/
23-
class DelayedHandlerSpringWebFluxServerTest extends HandlerSpringWebFluxServerTest {
24+
class DelayedHandlerSpringWebFluxServerTest extends AbstractHandlerSpringWebFluxServerTest {
2425
@Override
2526
protected Class<?> getApplicationClass() {
2627
return Application.class;
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,91 @@
1-
/*
2-
* Copyright The OpenTelemetry Authors
3-
* SPDX-License-Identifier: Apache-2.0
4-
*/
5-
6-
package io.opentelemetry.javaagent.instrumentation.spring.webflux.v5_0.server.base;
7-
8-
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION;
9-
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.NOT_FOUND;
10-
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
11-
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies;
12-
import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_MESSAGE;
13-
import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_STACKTRACE;
14-
import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_TYPE;
15-
16-
import io.opentelemetry.api.trace.SpanKind;
17-
import io.opentelemetry.instrumentation.api.internal.HttpConstants;
18-
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions;
19-
import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint;
20-
import io.opentelemetry.sdk.testing.assertj.SpanDataAssert;
21-
import io.opentelemetry.sdk.trace.data.StatusData;
22-
23-
public abstract class HandlerSpringWebFluxServerTest extends SpringWebFluxServerTest {
24-
25-
@Override
26-
protected SpanDataAssert assertHandlerSpan(
27-
SpanDataAssert span, String method, ServerEndpoint endpoint) {
28-
String handlerSpanName = ServerTestRouteFactory.class.getSimpleName() + "$$Lambda.handle";
29-
if (endpoint == NOT_FOUND) {
30-
handlerSpanName = "ResourceWebHandler.handle";
31-
}
32-
span.hasName(handlerSpanName).hasKind(SpanKind.INTERNAL);
33-
if (endpoint == EXCEPTION) {
34-
span.hasStatus(StatusData.error());
35-
span.hasEventsSatisfyingExactly(
36-
event ->
37-
event
38-
.hasName("exception")
39-
.hasAttributesSatisfyingExactly(
40-
equalTo(EXCEPTION_TYPE, "java.lang.IllegalStateException"),
41-
equalTo(EXCEPTION_MESSAGE, EXCEPTION.getBody()),
42-
satisfies(EXCEPTION_STACKTRACE, val -> val.isInstanceOf(String.class))));
43-
} else if (endpoint == NOT_FOUND) {
44-
span.hasStatus(StatusData.error());
45-
if (Boolean.getBoolean("testLatestDeps")) {
46-
span.hasEventsSatisfyingExactly(
47-
event ->
48-
event
49-
.hasName("exception")
50-
.hasAttributesSatisfyingExactly(
51-
equalTo(
52-
EXCEPTION_TYPE,
53-
"org.springframework.web.reactive.resource.NoResourceFoundException"),
54-
equalTo(
55-
EXCEPTION_MESSAGE, "404 NOT_FOUND \"No static resource notFound.\""),
56-
satisfies(EXCEPTION_STACKTRACE, val -> val.isInstanceOf(String.class))));
57-
} else {
58-
span.hasEventsSatisfyingExactly(
59-
event ->
60-
event
61-
.hasName("exception")
62-
.hasAttributesSatisfyingExactly(
63-
equalTo(
64-
EXCEPTION_TYPE,
65-
"org.springframework.web.server.ResponseStatusException"),
66-
equalTo(EXCEPTION_MESSAGE, "Response status 404"),
67-
satisfies(EXCEPTION_STACKTRACE, val -> val.isInstanceOf(String.class))));
68-
}
69-
}
70-
return span;
71-
}
72-
73-
@Override
74-
protected void configure(HttpServerTestOptions options) {
75-
super.configure(options);
76-
// TODO (trask) it seems like in this case ideally the controller span (which ends when the
77-
// Mono that the controller returns completes) should end before the server span (which needs
78-
// the result of the Mono)
79-
options.setVerifyServerSpanEndTime(false);
80-
81-
options.setResponseCodeOnNonStandardHttpMethod(404);
82-
}
83-
84-
@Override
85-
public String expectedHttpRoute(ServerEndpoint endpoint, String method) {
86-
if (HttpConstants._OTHER.equals(method)) {
87-
return getContextPath() + "/**";
88-
}
89-
return super.expectedHttpRoute(endpoint, method);
90-
}
91-
}
1+
///*
2+
// * Copyright The OpenTelemetry Authors
3+
// * SPDX-License-Identifier: Apache-2.0
4+
// */
5+
//
6+
//package io.opentelemetry.javaagent.instrumentation.spring.webflux.v5_0.server.base;
7+
//
8+
//import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION;
9+
//import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.NOT_FOUND;
10+
//import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
11+
//import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies;
12+
//import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_MESSAGE;
13+
//import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_STACKTRACE;
14+
//import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_TYPE;
15+
//
16+
//import io.opentelemetry.api.trace.SpanKind;
17+
//import io.opentelemetry.instrumentation.api.internal.HttpConstants;
18+
//import io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions;
19+
//import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint;
20+
//import io.opentelemetry.sdk.testing.assertj.SpanDataAssert;
21+
//import io.opentelemetry.sdk.trace.data.StatusData;
22+
//
23+
//public abstract class HandlerSpringWebFluxServerTest extends SpringWebFluxServerTest {
24+
//
25+
// @Override
26+
// protected SpanDataAssert assertHandlerSpan(
27+
// SpanDataAssert span, String method, ServerEndpoint endpoint) {
28+
// String handlerSpanName = ServerTestRouteFactory.class.getSimpleName() + "$$Lambda.handle";
29+
// if (endpoint == NOT_FOUND) {
30+
// handlerSpanName = "ResourceWebHandler.handle";
31+
// }
32+
// span.hasName(handlerSpanName).hasKind(SpanKind.INTERNAL);
33+
// if (endpoint == EXCEPTION) {
34+
// span.hasStatus(StatusData.error());
35+
// span.hasEventsSatisfyingExactly(
36+
// event ->
37+
// event
38+
// .hasName("exception")
39+
// .hasAttributesSatisfyingExactly(
40+
// equalTo(EXCEPTION_TYPE, "java.lang.IllegalStateException"),
41+
// equalTo(EXCEPTION_MESSAGE, EXCEPTION.getBody()),
42+
// satisfies(EXCEPTION_STACKTRACE, val -> val.isInstanceOf(String.class))));
43+
// } else if (endpoint == NOT_FOUND) {
44+
// span.hasStatus(StatusData.error());
45+
// if (Boolean.getBoolean("testLatestDeps")) {
46+
// span.hasEventsSatisfyingExactly(
47+
// event ->
48+
// event
49+
// .hasName("exception")
50+
// .hasAttributesSatisfyingExactly(
51+
// equalTo(
52+
// EXCEPTION_TYPE,
53+
// "org.springframework.web.reactive.resource.NoResourceFoundException"),
54+
// equalTo(
55+
// EXCEPTION_MESSAGE, "404 NOT_FOUND \"No static resource notFound.\""),
56+
// satisfies(EXCEPTION_STACKTRACE, val -> val.isInstanceOf(String.class))));
57+
// } else {
58+
// span.hasEventsSatisfyingExactly(
59+
// event ->
60+
// event
61+
// .hasName("exception")
62+
// .hasAttributesSatisfyingExactly(
63+
// equalTo(
64+
// EXCEPTION_TYPE,
65+
// "org.springframework.web.server.ResponseStatusException"),
66+
// equalTo(EXCEPTION_MESSAGE, "Response status 404"),
67+
// satisfies(EXCEPTION_STACKTRACE, val -> val.isInstanceOf(String.class))));
68+
// }
69+
// }
70+
// return span;
71+
// }
72+
//
73+
// @Override
74+
// protected void configure(HttpServerTestOptions options) {
75+
// super.configure(options);
76+
// // TODO (trask) it seems like in this case ideally the controller span (which ends when the
77+
// // Mono that the controller returns completes) should end before the server span (which needs
78+
// // the result of the Mono)
79+
// options.setVerifyServerSpanEndTime(false);
80+
//
81+
// options.setResponseCodeOnNonStandardHttpMethod(404);
82+
// }
83+
//
84+
// @Override
85+
// public String expectedHttpRoute(ServerEndpoint endpoint, String method) {
86+
// if (HttpConstants._OTHER.equals(method)) {
87+
// return getContextPath() + "/**";
88+
// }
89+
// return super.expectedHttpRoute(endpoint, method);
90+
// }
91+
//}

instrumentation/spring/spring-webflux/spring-webflux-5.0/testing-webflux7/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/v7_0/SpringThreadedSpringWebfluxTest.java renamed to instrumentation/spring/spring-webflux/spring-webflux-5.0/testing-webflux7/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/v7_0/server/SpringThreadedSpringWebfluxTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
package io.opentelemetry.javaagent.instrumentation.spring.webflux.v7_0;
6+
package io.opentelemetry.javaagent.instrumentation.spring.webflux.v7_0.server;
77

88
import org.springframework.boot.reactor.netty.NettyReactiveWebServerFactory;
99
import org.springframework.boot.test.context.SpringBootTest;

instrumentation/spring/spring-webflux/spring-webflux-5.0/testing-webflux7/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/v7_0/SpringWebfluxTest.java renamed to instrumentation/spring/spring-webflux/spring-webflux-5.0/testing-webflux7/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/v7_0/server/SpringWebfluxTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
package io.opentelemetry.javaagent.instrumentation.spring.webflux.v7_0;
6+
package io.opentelemetry.javaagent.instrumentation.spring.webflux.v7_0.server;
77

88
import io.opentelemetry.instrumentation.spring.webflux.server.AbstractSpringWebfluxTest;
99
import org.junit.jupiter.api.extension.ExtendWith;

instrumentation/spring/spring-webflux/spring-webflux-5.0/testing-webflux7/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/v7_0/server/base/DelayedHandlerSpringWebFluxServerTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package io.opentelemetry.javaagent.instrumentation.spring.webflux.v7_0.server.base;
77

8+
import io.opentelemetry.instrumentation.spring.webflux.server.AbstractHandlerSpringWebFluxServerTest;
89
import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint;
910
import java.time.Duration;
1011
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -20,7 +21,7 @@
2021
* map step, which follows a delay step. For exception endpoint, the exception is thrown within the
2122
* last map step.
2223
*/
23-
class DelayedHandlerSpringWebFluxServerTest extends HandlerSpringWebFluxServerTest {
24+
class DelayedHandlerSpringWebFluxServerTest extends AbstractHandlerSpringWebFluxServerTest {
2425
@Override
2526
protected Class<?> getApplicationClass() {
2627
return Application.class;
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,81 @@
1-
/*
2-
* Copyright The OpenTelemetry Authors
3-
* SPDX-License-Identifier: Apache-2.0
4-
*/
5-
6-
package io.opentelemetry.javaagent.instrumentation.spring.webflux.v7_0.server.base;
7-
8-
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION;
9-
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.NOT_FOUND;
10-
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
11-
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies;
12-
import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_MESSAGE;
13-
import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_STACKTRACE;
14-
import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_TYPE;
15-
16-
import io.opentelemetry.api.trace.SpanKind;
17-
import io.opentelemetry.instrumentation.api.internal.HttpConstants;
18-
import io.opentelemetry.instrumentation.spring.webflux.server.AbstractSpringWebFluxServerTest;
19-
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions;
20-
import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint;
21-
import io.opentelemetry.sdk.testing.assertj.SpanDataAssert;
22-
import io.opentelemetry.sdk.trace.data.StatusData;
23-
24-
public abstract class HandlerSpringWebFluxServerTest extends AbstractSpringWebFluxServerTest {
25-
26-
@Override
27-
protected SpanDataAssert assertHandlerSpan(
28-
SpanDataAssert span, String method, ServerEndpoint endpoint) {
29-
String handlerSpanName = ServerTestRouteFactory.class.getSimpleName() + "$$Lambda.handle";
30-
if (endpoint == NOT_FOUND) {
31-
handlerSpanName = "ResourceWebHandler.handle";
32-
}
33-
span.hasName(handlerSpanName).hasKind(SpanKind.INTERNAL);
34-
if (endpoint == EXCEPTION) {
35-
span.hasStatus(StatusData.error());
36-
span.hasEventsSatisfyingExactly(
37-
event ->
38-
event
39-
.hasName("exception")
40-
.hasAttributesSatisfyingExactly(
41-
equalTo(EXCEPTION_TYPE, "java.lang.IllegalStateException"),
42-
equalTo(EXCEPTION_MESSAGE, EXCEPTION.getBody()),
43-
satisfies(EXCEPTION_STACKTRACE, val -> val.isInstanceOf(String.class))));
44-
} else if (endpoint == NOT_FOUND) {
45-
span.hasStatus(StatusData.error());
46-
// Spring 7 uses NoResourceFoundException
47-
span.hasEventsSatisfyingExactly(
48-
event ->
49-
event
50-
.hasName("exception")
51-
.hasAttributesSatisfyingExactly(
52-
equalTo(
53-
EXCEPTION_TYPE,
54-
"org.springframework.web.reactive.resource.NoResourceFoundException"),
55-
equalTo(EXCEPTION_MESSAGE, "404 NOT_FOUND \"No static resource notFound.\""),
56-
satisfies(EXCEPTION_STACKTRACE, val -> val.isInstanceOf(String.class))));
57-
}
58-
return span;
59-
}
60-
61-
@Override
62-
protected void configure(HttpServerTestOptions options) {
63-
super.configure(options);
64-
// TODO (trask) it seems like in this case ideally the controller span (which ends when the
65-
// Mono that the controller returns completes) should end before the server span (which needs
66-
// the result of the Mono)
67-
options.setVerifyServerSpanEndTime(false);
68-
69-
options.setHasHandlerSpan(t -> false);
70-
71-
options.setResponseCodeOnNonStandardHttpMethod(404);
72-
}
73-
74-
@Override
75-
public String expectedHttpRoute(ServerEndpoint endpoint, String method) {
76-
if (HttpConstants._OTHER.equals(method)) {
77-
return getContextPath() + "/**";
78-
}
79-
return super.expectedHttpRoute(endpoint, method);
80-
}
81-
}
1+
///*
2+
// * Copyright The OpenTelemetry Authors
3+
// * SPDX-License-Identifier: Apache-2.0
4+
// */
5+
//
6+
//package io.opentelemetry.javaagent.instrumentation.spring.webflux.v7_0.server.base;
7+
//
8+
//import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION;
9+
//import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.NOT_FOUND;
10+
//import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
11+
//import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies;
12+
//import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_MESSAGE;
13+
//import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_STACKTRACE;
14+
//import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_TYPE;
15+
//
16+
//import io.opentelemetry.api.trace.SpanKind;
17+
//import io.opentelemetry.instrumentation.api.internal.HttpConstants;
18+
//import io.opentelemetry.instrumentation.spring.webflux.server.AbstractSpringWebFluxServerTest;
19+
//import io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions;
20+
//import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint;
21+
//import io.opentelemetry.sdk.testing.assertj.SpanDataAssert;
22+
//import io.opentelemetry.sdk.trace.data.StatusData;
23+
//
24+
//public abstract class HandlerSpringWebFluxServerTest extends AbstractSpringWebFluxServerTest {
25+
//
26+
// @Override
27+
// protected SpanDataAssert assertHandlerSpan(
28+
// SpanDataAssert span, String method, ServerEndpoint endpoint) {
29+
// String handlerSpanName = ServerTestRouteFactory.class.getSimpleName() + "$$Lambda.handle";
30+
// if (endpoint == NOT_FOUND) {
31+
// handlerSpanName = "ResourceWebHandler.handle";
32+
// }
33+
// span.hasName(handlerSpanName).hasKind(SpanKind.INTERNAL);
34+
// if (endpoint == EXCEPTION) {
35+
// span.hasStatus(StatusData.error());
36+
// span.hasEventsSatisfyingExactly(
37+
// event ->
38+
// event
39+
// .hasName("exception")
40+
// .hasAttributesSatisfyingExactly(
41+
// equalTo(EXCEPTION_TYPE, "java.lang.IllegalStateException"),
42+
// equalTo(EXCEPTION_MESSAGE, EXCEPTION.getBody()),
43+
// satisfies(EXCEPTION_STACKTRACE, val -> val.isInstanceOf(String.class))));
44+
// } else if (endpoint == NOT_FOUND) {
45+
// span.hasStatus(StatusData.error());
46+
// // Spring 7 uses NoResourceFoundException
47+
// span.hasEventsSatisfyingExactly(
48+
// event ->
49+
// event
50+
// .hasName("exception")
51+
// .hasAttributesSatisfyingExactly(
52+
// equalTo(
53+
// EXCEPTION_TYPE,
54+
// "org.springframework.web.reactive.resource.NoResourceFoundException"),
55+
// equalTo(EXCEPTION_MESSAGE, "404 NOT_FOUND \"No static resource notFound.\""),
56+
// satisfies(EXCEPTION_STACKTRACE, val -> val.isInstanceOf(String.class))));
57+
// }
58+
// return span;
59+
// }
60+
//
61+
// @Override
62+
// protected void configure(HttpServerTestOptions options) {
63+
// super.configure(options);
64+
// // TODO (trask) it seems like in this case ideally the controller span (which ends when the
65+
// // Mono that the controller returns completes) should end before the server span (which needs
66+
// // the result of the Mono)
67+
// options.setVerifyServerSpanEndTime(false);
68+
//
69+
// options.setHasHandlerSpan(t -> false);
70+
//
71+
// options.setResponseCodeOnNonStandardHttpMethod(404);
72+
// }
73+
//
74+
// @Override
75+
// public String expectedHttpRoute(ServerEndpoint endpoint, String method) {
76+
// if (HttpConstants._OTHER.equals(method)) {
77+
// return getContextPath() + "/**";
78+
// }
79+
// return super.expectedHttpRoute(endpoint, method);
80+
// }
81+
//}

0 commit comments

Comments
 (0)