Test latest struts 6.x version (#12948)

This commit is contained in:
Lauri Tulmin 2024-12-22 18:48:08 +02:00 committed by GitHub
parent aeb1b787ce
commit f30601d3e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -27,7 +27,7 @@ dependencies {
testInstrumentation(project(":instrumentation:jetty:jetty-8.0:javaagent")) testInstrumentation(project(":instrumentation:jetty:jetty-8.0:javaagent"))
testInstrumentation(project(":instrumentation:struts:struts-7.0:javaagent")) testInstrumentation(project(":instrumentation:struts:struts-7.0:javaagent"))
latestDepTestLibrary("org.apache.struts:struts2-core:6.0.+") latestDepTestLibrary("org.apache.struts:struts2-core:6.+")
} }
tasks.withType<Test>().configureEach { tasks.withType<Test>().configureEach {

View File

@ -5,12 +5,14 @@
package io.opentelemetry.javaagent.instrumentation.struts.v7_0; package io.opentelemetry.javaagent.instrumentation.struts.v7_0;
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
import static java.util.Collections.singletonList; import static java.util.Collections.singletonList;
import com.google.auto.service.AutoService; import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import java.util.List; import java.util.List;
import net.bytebuddy.matcher.ElementMatcher;
@AutoService(InstrumentationModule.class) @AutoService(InstrumentationModule.class)
public class Struts2InstrumentationModule extends InstrumentationModule { public class Struts2InstrumentationModule extends InstrumentationModule {
@ -19,6 +21,12 @@ public class Struts2InstrumentationModule extends InstrumentationModule {
super("struts", "struts-7.0"); super("struts", "struts-7.0");
} }
@Override
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
// class is in different package before 7.0
return hasClassesNamed("org.apache.struts2.config.entities.ActionConfig");
}
@Override @Override
public List<TypeInstrumentation> typeInstrumentations() { public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new ActionInvocationInstrumentation()); return singletonList(new ActionInvocationInstrumentation());