Support just released Javalin 7#16261
Merged
laurit merged 1 commit intoopen-telemetry:mainfrom Feb 25, 2026
Merged
Conversation
trask
commented
Feb 22, 2026
Member
Author
There was a problem hiding this comment.
Basically copy of old JavalinTest
git diff -w upstream/main:instrumentation/javalin-5.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/javalin/v5_0/JavalinTest.java -- instrumentation/javalin/testing/src/main/java/io/opentelemetry/instrumentation/javalin/AbstractJavalinTest.java
diff --git a/instrumentation/javalin-5.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/javalin/v5_0/JavalinTest.java b/instrumentation/javalin/testing/src/main/java/io/opentelemetry/instrumentation/javalin/AbstractJavalinTest.java
index 5ea3fe578a..668bcb823a 100644
--- a/instrumentation/javalin-5.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/javalin/v5_0/JavalinTest.java
+++ b/instrumentation/javalin/testing/src/main/java/io/opentelemetry/instrumentation/javalin/AbstractJavalinTest.java
@@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
-package io.opentelemetry.javaagent.instrumentation.javalin.v5_0;
+package io.opentelemetry.instrumentation.javalin;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
@@ -21,39 +21,45 @@ import static io.opentelemetry.semconv.ServerAttributes.SERVER_PORT;
import static io.opentelemetry.semconv.UrlAttributes.URL_PATH;
import static io.opentelemetry.semconv.UrlAttributes.URL_SCHEME;
import static io.opentelemetry.semconv.UserAgentAttributes.USER_AGENT_ORIGINAL;
+import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
import io.javalin.Javalin;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.test.utils.PortUtils;
-import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.testing.internal.armeria.client.WebClient;
import io.opentelemetry.testing.internal.armeria.common.AggregatedHttpResponse;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.api.TestInstance;
-class JavalinTest {
+@TestInstance(PER_CLASS)
+public abstract class AbstractJavalinTest {
- @RegisterExtension
- private static final InstrumentationExtension testing = AgentInstrumentationExtension.create();
+ protected abstract InstrumentationExtension testing();
- private static Javalin app;
- private static int port;
- private static WebClient client;
+ protected abstract Javalin setupJavalin(int port);
+
+ protected abstract String getJettyInstrumentation();
+
+ private Javalin app;
+ private int port;
+ private WebClient client;
@BeforeAll
- static void setup() {
+ void setup() {
port = PortUtils.findOpenPort();
- app = TestJavalinJavaApplication.initJavalin(port);
+ app = setupJavalin(port);
client = WebClient.of("http://localhost:" + port);
}
@AfterAll
- static void cleanup() {
+ void cleanup() {
+ if (app != null) {
app.stop();
}
+ }
@Test
void testSpanNameAndHttpRouteSpanWithPathParamResponseSuccessful() {
@@ -63,7 +69,8 @@ class JavalinTest {
assertThat(content).isEqualTo(id);
assertThat(response.status().code()).isEqualTo(200);
- testing.waitAndAssertTraces(
+ testing()
+ .waitAndAssertTraces(
trace ->
trace.hasSpansSatisfyingExactly(
span ->
@@ -75,21 +82,24 @@ class JavalinTest {
equalTo(URL_PATH, "/param/" + id),
equalTo(HTTP_REQUEST_METHOD, "GET"),
equalTo(HTTP_RESPONSE_STATUS_CODE, 200),
- satisfies(USER_AGENT_ORIGINAL, val -> val.isInstanceOf(String.class)),
+ satisfies(
+ USER_AGENT_ORIGINAL, val -> val.isInstanceOf(String.class)),
equalTo(HTTP_ROUTE, "/param/{id}"),
equalTo(NETWORK_PROTOCOL_VERSION, "1.1"),
equalTo(SERVER_ADDRESS, "localhost"),
equalTo(SERVER_PORT, port),
equalTo(CLIENT_ADDRESS, "127.0.0.1"),
equalTo(NETWORK_PEER_ADDRESS, "127.0.0.1"),
- satisfies(NETWORK_PEER_PORT, val -> val.isInstanceOf(Long.class)))));
+ satisfies(
+ NETWORK_PEER_PORT, val -> val.isInstanceOf(Long.class)))));
}
@Test
void testSpanNameAndHttpRouteSpanResponseError() {
client.get("/error").aggregate().join();
- testing.waitAndAssertTraces(
+ testing()
+ .waitAndAssertTraces(
trace ->
trace.hasSpansSatisfyingExactly(
span ->
@@ -101,7 +111,8 @@ class JavalinTest {
equalTo(URL_PATH, "/error"),
equalTo(HTTP_REQUEST_METHOD, "GET"),
equalTo(HTTP_RESPONSE_STATUS_CODE, 500),
- satisfies(USER_AGENT_ORIGINAL, val -> val.isInstanceOf(String.class)),
+ satisfies(
+ USER_AGENT_ORIGINAL, val -> val.isInstanceOf(String.class)),
equalTo(HTTP_ROUTE, "/error"),
equalTo(NETWORK_PROTOCOL_VERSION, "1.1"),
equalTo(SERVER_ADDRESS, "localhost"),
@@ -109,15 +120,17 @@ class JavalinTest {
equalTo(ERROR_TYPE, "500"),
equalTo(CLIENT_ADDRESS, "127.0.0.1"),
equalTo(NETWORK_PEER_ADDRESS, "127.0.0.1"),
- satisfies(NETWORK_PEER_PORT, val -> val.isInstanceOf(Long.class)))));
+ satisfies(
+ NETWORK_PEER_PORT, val -> val.isInstanceOf(Long.class)))));
}
@Test
- public void testSpanNameAndHttpRouteSpanAsyncRouteResponseSuccessful() {
+ void testSpanNameAndHttpRouteSpanAsyncRouteResponseSuccessful() {
AggregatedHttpResponse response = client.get("/async").aggregate().join();
assertThat(response.status().code()).isEqualTo(200);
- testing.waitAndAssertTraces(
+ testing()
+ .waitAndAssertTraces(
trace ->
trace.hasSpansSatisfyingExactly(
span ->
@@ -129,14 +142,16 @@ class JavalinTest {
equalTo(URL_PATH, "/async"),
equalTo(HTTP_REQUEST_METHOD, "GET"),
equalTo(HTTP_RESPONSE_STATUS_CODE, 200),
- satisfies(USER_AGENT_ORIGINAL, val -> val.isInstanceOf(String.class)),
+ satisfies(
+ USER_AGENT_ORIGINAL, val -> val.isInstanceOf(String.class)),
equalTo(HTTP_ROUTE, "/async"),
equalTo(NETWORK_PROTOCOL_VERSION, "1.1"),
equalTo(SERVER_ADDRESS, "localhost"),
equalTo(SERVER_PORT, port),
equalTo(CLIENT_ADDRESS, "127.0.0.1"),
equalTo(NETWORK_PEER_ADDRESS, "127.0.0.1"),
- satisfies(NETWORK_PEER_PORT, val -> val.isInstanceOf(Long.class)))));
+ satisfies(
+ NETWORK_PEER_PORT, val -> val.isInstanceOf(Long.class)))));
}
@Test
@@ -144,12 +159,12 @@ class JavalinTest {
String id = "123";
AggregatedHttpResponse response = client.get("/param/" + id).aggregate().join();
String content = response.contentUtf8();
- String instrumentation = "io.opentelemetry.jetty-11.0";
assertThat(content).isEqualTo(id);
assertThat(response.status().code()).isEqualTo(200);
- testing.waitAndAssertMetrics(
- instrumentation,
+ testing()
+ .waitAndAssertMetrics(
+ getJettyInstrumentation(),
"http.server.request.duration",
metrics ->
metrics.anySatisfy(
trask
commented
Feb 22, 2026
Member
Author
There was a problem hiding this comment.
diff with 5.0 version:
git diff --no-index -- instrumentation/javalin/javalin-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/javalin/v5_0/JavalinInstrumentation.java instrumentation/javalin/javalin-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/javalin/v7_0/JavalinInstrumentation.java
diff --git a/instrumentation/javalin/javalin-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/javalin/v5_0/JavalinInstrumentation.java b/instrumentation/javalin/javalin-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/javalin/v7_0/JavalinInstrumentation.java
index b7ae2a4a5d..0d6f1c315a 100644
--- a/instrumentation/javalin/javalin-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/javalin/v5_0/JavalinInstrumentation.java
+++ b/instrumentation/javalin/javalin-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/javalin/v7_0/JavalinInstrumentation.java
@@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
-package io.opentelemetry.javaagent.instrumentation.javalin.v5_0;
+package io.opentelemetry.javaagent.instrumentation.javalin.v7_0;
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasSuperType;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
@@ -42,7 +42,7 @@ public class JavalinInstrumentation implements TypeInstrumentation {
HttpServerRoute.update(
io.opentelemetry.context.Context.current(),
HttpServerRouteSource.CONTROLLER,
- ctx.endpointHandlerPath());
+ ctx.endpoint().path);
}
}
}c0e9033 to
c01a6ef
Compare
Member
Author
|
/easycla |
zeitlinger
added a commit
to zeitlinger/opentelemetry-java-instrumentation
that referenced
this pull request
Feb 24, 2026
Javalin 6.x changed the routing API (app.get() signature), breaking test compilation. Cap latestDepTestLibrary to 5.+ until open-telemetry#16261 adds proper Javalin 7 support. See open-telemetry#16261 Signed-off-by: Gregor Zeitlinger <[email protected]>
zeitlinger
added a commit
to zeitlinger/opentelemetry-java-instrumentation
that referenced
this pull request
Feb 24, 2026
Javalin 6.x changed the routing API (app.get() signature), breaking test compilation. Cap latestDepTestLibrary to 5.+ until open-telemetry#16261 adds proper Javalin 7 support. See open-telemetry#16261 Signed-off-by: Gregor Zeitlinger <[email protected]>
zeitlinger
added a commit
to zeitlinger/opentelemetry-java-instrumentation
that referenced
this pull request
Feb 24, 2026
Javalin 6.x changed the routing API (app.get() signature), breaking test compilation. Cap latestDepTestLibrary to 5.+ until open-telemetry#16261 adds proper Javalin 7 support. See open-telemetry#16261 Signed-off-by: Gregor Zeitlinger <[email protected]>
1 task
zeitlinger
added a commit
to zeitlinger/opentelemetry-java-instrumentation
that referenced
this pull request
Feb 24, 2026
Javalin 6.x changed the routing API (app.get() signature), breaking test compilation. Cap latestDepTestLibrary to 5.+ until open-telemetry#16261 adds proper Javalin 7 support. See open-telemetry#16261 Signed-off-by: Gregor Zeitlinger <[email protected]>
laurit
approved these changes
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.