Skip to content

Commit 3754062

Browse files
traskCopilot
andauthored
Gate Wicket resource span names on v3 preview (#18775)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent f6f123d commit 3754062

4 files changed

Lines changed: 37 additions & 2 deletions

File tree

instrumentation/wicket-8.0/common-testing/src/main/java/io/opentelemetry/javaagent/instrumentation/wicket/v8_0/AbstractWicketTest.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
abstract class AbstractWicketTest<SERVER> extends AbstractHttpServerUsingTest<SERVER> {
2424

25+
private static final boolean V3_PREVIEW =
26+
Boolean.getBoolean("otel.instrumentation.common.v3-preview");
27+
2528
@RegisterExtension
2629
private static final InstrumentationExtension testing =
2730
HttpServerInstrumentationExtension.forAgent();
@@ -89,8 +92,15 @@ void testResource() {
8992
trace ->
9093
trace.hasSpansSatisfyingExactly(
9194
span ->
92-
span.hasName("GET " + getContextPath() + "/wicket-test/hello.HelloResource")
95+
span.hasName(expectedResourceSpanName())
9396
.hasKind(SpanKind.SERVER)
9497
.hasNoParent()));
9598
}
99+
100+
private String expectedResourceSpanName() {
101+
if (V3_PREVIEW) {
102+
return "GET " + getContextPath() + "/wicket-test/hello.HelloResource";
103+
}
104+
return "GET " + getContextPath() + "/wicket-test/*";
105+
}
96106
}

instrumentation/wicket-8.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/wicket/v8_0/RequestHandlerExecutorInstrumentation.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.wicket.v8_0;
77

8+
import static io.opentelemetry.instrumentation.api.internal.SemconvStability.v3Preview;
89
import static io.opentelemetry.instrumentation.api.semconv.http.HttpServerRouteSource.CONTROLLER;
910
import static io.opentelemetry.javaagent.instrumentation.wicket.v8_0.WicketServerSpanNaming.serverSpanName;
1011
import static io.opentelemetry.javaagent.instrumentation.wicket.v8_0.WicketServerSpanNaming.serverSpanNameResource;
@@ -48,7 +49,7 @@ public static void onEnter(@Advice.Argument(0) IRequestHandler handler) {
4849
serverSpanName(),
4950
(IPageClassRequestHandler) handler);
5051
}
51-
if (handler instanceof ResourceReferenceRequestHandler) {
52+
if (handler instanceof ResourceReferenceRequestHandler && v3Preview()) {
5253
HttpServerRoute.update(
5354
Java8BytecodeBridge.currentContext(),
5455
CONTROLLER,

instrumentation/wicket-8.0/wicket10-testing/build.gradle.kts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,15 @@ dependencies {
1616
otelJava {
1717
minJavaVersionSupported.set(JavaVersion.VERSION_17)
1818
}
19+
20+
tasks {
21+
val testV3Preview by registering(Test::class) {
22+
testClassesDirs = sourceSets.test.get().output.classesDirs
23+
classpath = sourceSets.test.get().runtimeClasspath
24+
jvmArgs("-Dotel.instrumentation.common.v3-preview=true")
25+
}
26+
27+
check {
28+
dependsOn(testV3Preview)
29+
}
30+
}

instrumentation/wicket-8.0/wicket8-testing/build.gradle.kts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,15 @@ if (otelProps.testLatestDeps) {
2121
minJavaVersionSupported.set(JavaVersion.VERSION_11)
2222
}
2323
}
24+
25+
tasks {
26+
val testV3Preview by registering(Test::class) {
27+
testClassesDirs = sourceSets.test.get().output.classesDirs
28+
classpath = sourceSets.test.get().runtimeClasspath
29+
jvmArgs("-Dotel.instrumentation.common.v3-preview=true")
30+
}
31+
32+
check {
33+
dependsOn(testV3Preview)
34+
}
35+
}

0 commit comments

Comments
 (0)