Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ variables:
BUILD_JOB_NAME: "build"
DEPENDENCY_CACHE_POLICY: pull
BUILD_CACHE_POLICY: pull
GRADLE_VERSION: "9.7.0" # must match gradle-wrapper.properties
GRADLE_VERSION: "9.7.1" # must match gradle-wrapper.properties
MASS_READ_URL: "https://mass-read.us1.ddbuild.io"
MAVEN_REPOSITORY_PROXY: "https://depot-read-api-java.us1.ddbuild.io/magicmirror/magicmirror/@current/"
GRADLE_PLUGIN_PROXY: "https://depot-read-api-java.us1.ddbuild.io/magicmirror/magicmirror/@current/"
Expand Down
1 change: 1 addition & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ dependencyResolutionManagement {
rootProject.name = "build-logic"

include(":conventions")
include(":spring-boot-shadow")
include(":smoke-test")
19 changes: 19 additions & 0 deletions build-logic/spring-boot-shadow/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
`kotlin-dsl`
}

// Shadow 9's plugin API targets Java 17, so keep it isolated from Java 8 build-logic modules.
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlin {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
}
}

dependencies {
implementation("com.gradleup.shadow:shadow-gradle-plugin:${libs.versions.shadow.get()}")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.github.jengelman.gradle.plugins.shadow.transformers.PropertiesFileTransformer

plugins {
id("com.gradleup.shadow")
}

tasks.withType<ShadowJar>().configureEach {
if (name == "shadowJar") {
// `configurations` is left at its convention, which the Shadow plugin already sets to
// `runtimeClasspath`; adding it again is a no-op because the property is a `SetProperty`.

// Spring discovery metadata can occur in multiple dependency jars. With enhanced graph
// ordering, keeping only the first duplicate may omit required registrations.
duplicatesStrategy = DuplicatesStrategy.INCLUDE
mergeServiceFiles()
append("META-INF/spring.handlers")
append("META-INF/spring.schemas")
append("META-INF/spring.tooling")
transform(PropertiesFileTransformer::class.java) {
paths.set(listOf("META-INF/spring.factories"))
mergeStrategy.set(PropertiesFileTransformer.MergeStrategy.Append)
}
filesNotMatching(
listOf(
"META-INF/services/**",
"META-INF/spring.handlers",
"META-INF/spring.schemas",
"META-INF/spring.tooling",
"META-INF/spring.factories",
)
) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}
}
18 changes: 17 additions & 1 deletion components/http/http-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,21 @@ dependencies {
// testRuntimeOnly(project(":components:http:http-lib-jdk"))
// testRuntimeOnly(project(":components:http:http-lib-okhttp"))
// Add MockServer for test fixtures
testFixturesImplementation("org.mock-server:mockserver-junit-jupiter-no-dependencies:5.14.0")
// Avoid mockserver-junit-jupiter-no-dependencies: its embedded JUnit classes can shadow ours.
testFixturesImplementation(libs.junit.jupiter)
// DO NOT BUMP THIS VERSION WITHOUT CHECKING THE JAR CONTENTS.
//
// The `-no-dependencies` artifacts relocate most of their dependencies under `shaded_package`,
// but leave `org.slf4j` unrelocated. That jar sorts ahead of `slf4j-api` on the test runtime
// classpath, so whichever slf4j API it embeds is the one that gets loaded:
// * 5.14.0 embeds the slf4j 1.7 API, which matches the slf4j-api version used here, and
// ships no binding of its own, so logback-classic still binds normally.
// * 5.15.0 embeds the slf4j 2.0 API plus a
// `META-INF/services/org.slf4j.spi.SLF4JServiceProvider` pointing at
// `org.slf4j.jul.JULServiceProvider`. slf4j 2.0 ignores logback 1.2's
// `org.slf4j.impl.StaticLoggerBinder`, so test logging silently reroutes to JUL.
//
// Switching to the non-shaded `org.mock-server:mockserver-netty` would remove the hazard
// entirely by letting Gradle arbitrate slf4j, at the cost of many transitives.
testFixturesImplementation("org.mock-server:mockserver-netty-no-dependencies:5.14.0")
}
20 changes: 10 additions & 10 deletions components/http/http-api/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ org.apache.commons:commons-lang3:3.20.0=spotbugs
org.apache.commons:commons-text:1.15.0=spotbugs
org.apache.logging.log4j:log4j-api:2.26.1=spotbugs
org.apache.logging.log4j:log4j-core:2.26.1=spotbugs
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testFixturesCompileClasspath
org.codehaus.groovy:groovy-ant:3.0.23=codenarc
org.codehaus.groovy:groovy-docgenerator:3.0.23=codenarc
org.codehaus.groovy:groovy-groovydoc:3.0.23=codenarc
Expand All @@ -44,19 +44,19 @@ org.jacoco:org.jacoco.agent:0.8.15=jacocoAgent,jacocoAnt
org.jacoco:org.jacoco.ant:0.8.15=jacocoAnt
org.jacoco:org.jacoco.core:0.8.15=jacocoAnt
org.jacoco:org.jacoco.report:0.8.15=jacocoAnt
org.junit.jupiter:junit-jupiter-api:5.14.1=testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-engine:5.14.1=testRuntimeClasspath
org.junit.jupiter:junit-jupiter-params:5.14.1=testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter:5.14.1=testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-commons:1.14.1=testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-engine:1.14.1=testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-api:5.14.1=testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-engine:5.14.1=testFixturesRuntimeClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-params:5.14.1=testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter:5.14.1=testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-commons:1.14.1=testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-engine:1.14.1=testCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-launcher:1.14.1=testRuntimeClasspath
org.junit:junit-bom:5.14.1=testCompileClasspath,testRuntimeClasspath
org.junit:junit-bom:5.14.1=testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath
org.junit:junit-bom:6.1.2=spotbugs
org.mock-server:mockserver-junit-jupiter-no-dependencies:5.14.0=testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath
org.mock-server:mockserver-netty-no-dependencies:5.14.0=testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath
org.mockito:mockito-core:4.4.0=testRuntimeClasspath
org.objenesis:objenesis:3.3=testCompileClasspath,testRuntimeClasspath
org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath
org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath
org.ow2.asm:asm-analysis:9.10.1=spotbugs
org.ow2.asm:asm-commons:9.10.1=jacocoAnt,spotbugs
org.ow2.asm:asm-tree:9.10.1=jacocoAnt,spotbugs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockserver.integration.ClientAndServer;
import org.mockserver.junit.jupiter.MockServerExtension;

@ExtendWith(MockServerExtension.class)
public class HttpClientAsyncTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockserver.integration.ClientAndServer;
import org.mockserver.junit.jupiter.MockServerExtension;

@ExtendWith(MockServerExtension.class)
public class HttpClientTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockserver.integration.ClientAndServer;
import org.mockserver.junit.jupiter.MockServerExtension;

@ExtendWith(MockServerExtension.class)
public class HttpResponseTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package datadog.http.client;

import static org.mockserver.integration.ClientAndServer.startClientAndServer;

import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ParameterContext;
import org.junit.jupiter.api.extension.ParameterResolutionException;
import org.junit.jupiter.api.extension.ParameterResolver;
import org.mockserver.client.MockServerClient;
import org.mockserver.integration.ClientAndServer;

/** Minimal JUnit lifecycle adapter for the shaded MockServer server artifact. */
public final class MockServerExtension
implements ParameterResolver, BeforeAllCallback, AfterAllCallback {
private ClientAndServer server;

@Override
public void beforeAll(ExtensionContext context) {
this.server = startClientAndServer(0);
}

@Override
public boolean supportsParameter(
ParameterContext parameterContext, ExtensionContext extensionContext) {
return MockServerClient.class.isAssignableFrom(parameterContext.getParameter().getType());
}

@Override
public Object resolveParameter(
ParameterContext parameterContext, ExtensionContext extensionContext) {
if (this.server == null) {
throw new ParameterResolutionException("MockServer has not been started");
}
return this.server;
}

@Override
public void afterAll(ExtensionContext context) {
if (this.server != null && this.server.isRunning()) {
this.server.stop();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ dependencies {
testImplementation project(':dd-java-agent:appsec:appsec-test-fixtures')
testRuntimeOnly project(':dd-java-agent:instrumentation:osgi-4.3')
testRuntimeOnly files(filterLogbackClassic.map { it.destinationDir })
// Keep shared classloader naming and multipart hooks under test without duplicating them.
testRuntimeOnly project(':dd-java-agent:instrumentation:liberty:liberty-common')
testRuntimeOnly project(':dd-java-agent:instrumentation:servlet:javax-servlet:javax-servlet-3.0')

testImplementation(libs.groovy.xml)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package datadog.trace.instrumentation.liberty20;

import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.implementsInterface;
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static datadog.trace.bootstrap.instrumentation.api.AgentSpan.fromContext;
import static datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator.DD_CONTEXT_ATTRIBUTE;
Expand All @@ -16,10 +17,14 @@
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

@AutoService(InstrumenterModule.class)
public class RequestFinishInstrumentation extends InstrumenterModule.Tracing
implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice {
implements Instrumenter.ForSingleType,
Instrumenter.WithTypeStructure,
Instrumenter.HasMethodAdvice {

public RequestFinishInstrumentation() {
super("liberty");
Expand All @@ -42,6 +47,12 @@ public String instrumentedType() {
return "com.ibm.ws.webcontainer.srt.SRTServletRequest";
}

@Override
public ElementMatcher<TypeDescription> structureMatcher() {
// Liberty keeps this class name across the javax-to-jakarta servlet migration.
return implementsInterface(named("javax.servlet.http.HttpServletRequest"));
}

@Override
public void methodAdvice(MethodTransformer transformer) {
transformer.applyAdvice(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package datadog.trace.instrumentation.liberty20;

import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.implementsInterface;
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static datadog.trace.bootstrap.instrumentation.api.AgentSpan.fromContext;
import static datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator.DD_CONTEXT_ATTRIBUTE;
Expand All @@ -18,6 +19,8 @@
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

/**
* XXX: {@link SRTServletResponse#finish()} is not appropriate method to look at the response
Expand All @@ -28,7 +31,9 @@
*/
@AutoService(InstrumenterModule.class)
public class ResponseFinishInstrumentation extends InstrumenterModule.Tracing
implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice {
implements Instrumenter.ForSingleType,
Instrumenter.WithTypeStructure,
Instrumenter.HasMethodAdvice {

public ResponseFinishInstrumentation() {
super("liberty");
Expand All @@ -51,6 +56,12 @@ public String instrumentedType() {
return "com.ibm.ws.webcontainer.srt.SRTServletResponse";
}

@Override
public ElementMatcher<TypeDescription> structureMatcher() {
// Liberty keeps this class name across the javax-to-jakarta servlet migration.
return implementsInterface(named("javax.servlet.http.HttpServletResponse"));
}

@Override
public void methodAdvice(MethodTransformer transformer) {
transformer.applyAdvice(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ dependencies {
testImplementation project(':dd-java-agent:appsec:appsec-test-fixtures')
testRuntimeOnly project(':dd-java-agent:instrumentation:osgi-4.3')
testRuntimeOnly files(filterLogbackClassic.map { it.destinationDir })
testRuntimeOnly project(':dd-java-agent:instrumentation:liberty:liberty-20.0')
// Reuse shared classloader naming and multipart hooks without loading javax instrumentation.
testRuntimeOnly project(':dd-java-agent:instrumentation:liberty:liberty-common')
testRuntimeOnly project(':dd-java-agent:instrumentation:servlet:jakarta-servlet-5.0')
testRuntimeOnly files(shadowJar.map { it.archiveFile })

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package datadog.trace.instrumentation.liberty23;

import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.implementsInterface;
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static datadog.trace.bootstrap.instrumentation.api.AgentSpan.fromContext;
import static datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator.DD_CONTEXT_ATTRIBUTE;
Expand All @@ -16,10 +17,14 @@
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

@AutoService(InstrumenterModule.class)
public class RequestFinishInstrumentation extends InstrumenterModule.Tracing
implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice {
implements Instrumenter.ForSingleType,
Instrumenter.WithTypeStructure,
Instrumenter.HasMethodAdvice {

public RequestFinishInstrumentation() {
super("liberty");
Expand All @@ -42,6 +47,12 @@ public String instrumentedType() {
return "com.ibm.ws.webcontainer.srt.SRTServletRequest";
}

@Override
public ElementMatcher<TypeDescription> structureMatcher() {
// Liberty keeps this class name across the javax-to-jakarta servlet migration.
return implementsInterface(named("jakarta.servlet.http.HttpServletRequest"));
}

@Override
public void methodAdvice(MethodTransformer transformer) {
transformer.applyAdvice(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package datadog.trace.instrumentation.liberty23;

import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.implementsInterface;
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static datadog.trace.bootstrap.instrumentation.api.AgentSpan.fromContext;
import static datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator.DD_CONTEXT_ATTRIBUTE;
Expand All @@ -18,6 +19,8 @@
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

/**
* XXX: {@link SRTServletResponse#finish()} is not appropriate method to look at the response
Expand All @@ -28,7 +31,9 @@
*/
@AutoService(InstrumenterModule.class)
public class ResponseFinishInstrumentation extends InstrumenterModule.Tracing
implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice {
implements Instrumenter.ForSingleType,
Instrumenter.WithTypeStructure,
Instrumenter.HasMethodAdvice {

public ResponseFinishInstrumentation() {
super("liberty");
Expand All @@ -51,6 +56,12 @@ public String instrumentedType() {
return "com.ibm.ws.webcontainer.srt.SRTServletResponse";
}

@Override
public ElementMatcher<TypeDescription> structureMatcher() {
// Liberty keeps this class name across the javax-to-jakarta servlet migration.
return implementsInterface(named("jakarta.servlet.http.HttpServletResponse"));
}

@Override
public void methodAdvice(MethodTransformer transformer) {
transformer.applyAdvice(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
id 'dd-trace-java.module.instrumentation'
}
Loading