Skip to content

Commit abe7711

Browse files
authored
Load jetty-server instrumentation in dropwizard-0.8 tests (#11235)
Load jetty-server instrumentation in dropwizard-0.8 tests Dropwizard 0.8 runs on Jetty 9.2.9, where jetty-server owns the request span in production. Add jetty-server-9.0 and jetty-server-9.0.4 as test dependencies so the test classpath matches, and update the expected integration name on DropwizardTest accordingly. Merge branch 'master' into smola/dropwizard-uses-jetty Co-authored-by: santiago.mola <santiago.mola@datadoghq.com>
1 parent c716a4c commit abe7711

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

dd-java-agent/instrumentation/dropwizard/dropwizard-0.8/build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ apply from: "$rootDir/gradle/java.gradle"
55
dependencies {
66
testImplementation project(':dd-java-agent:instrumentation:rs:jax-rs:jax-rs-annotations:jax-rs-annotations-2.0')
77
testImplementation project(':dd-java-agent:instrumentation:servlet:javax-servlet:javax-servlet-3.0')
8+
// Dropwizard 0.8 transitively depends on Jetty 9.2.9, so load the jetty-server
9+
// instrumentation modules whose muzzle ranges cover that version, matching the
10+
// production classpath:
11+
// - jetty-server-9.0 applies to [9, 10) and owns the request span
12+
// - jetty-server-9.0.4 applies to [9.0.4, 9.3.0.M1) and owns the AppSec
13+
// response-commit hook used by Jetty 9.2.x
14+
// Without these, the server span is owned by Servlet3Decorator.
15+
testImplementation project(':dd-java-agent:instrumentation:jetty:jetty-server:jetty-server-9.0')
16+
testImplementation project(':dd-java-agent:instrumentation:jetty:jetty-server:jetty-server-9.0.4')
817

918
// First version with DropwizardTestSupport:
1019
testImplementation group: 'io.dropwizard', name: 'dropwizard-testing', version: '0.8.0'

dd-java-agent/instrumentation/dropwizard/dropwizard-0.8/src/test/groovy/DropwizardTest.groovy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ class DropwizardTest extends HttpServerTest<DropwizardTestSupport> {
9595

9696
@Override
9797
String expectedIntegrationName() {
98-
"java-web-servlet"
98+
// In production, Jetty's server instrumentation creates the request span before Servlet3
99+
// gets a chance to. Servlet3Advice detects the existing span and skips, so the span is
100+
// owned by jetty-server, not java-web-servlet.
101+
"jetty-server"
99102
}
100103

101104
@Override

0 commit comments

Comments
 (0)