Move constants to decorator
MODIFY
dd-java-agent/instrumentation/jax-rs-annotations-2/filter-jersey/src/main/java/datadog/trace/instrumentation/jaxrs2/JerseyRequestContextInstrumentation.java
dd-java-agent/instrumentation/jax-rs-annotations-2/filter-jersey/src/main/java/datadog/trace/instrumentation/jaxrs2/JerseyRequestContextInstrumentation.java
@@ -17,7 +17,7 @@ public class JerseyRequestContextInstrumentation extends AbstractRequestContextI
public static AgentScope decorateAbortSpan(@Advice.This final ContainerRequestContext context) {
final UriInfo uriInfo = context.getUriInfo();
- if (context.getProperty(ContainerRequestFilterInstrumentation.ABORT_HANDLED) == null
+ if (context.getProperty(JaxRsAnnotationsDecorator.ABORT_HANDLED) == null
&& uriInfo instanceof ResourceInfo) {
final ResourceInfo resourceInfo = (ResourceInfo) uriInfo;

MODIFY
dd-java-agent/instrumentation/jax-rs-annotations-2/filter-resteasy-3.0/src/main/java/datadog/trace/instrumentation/jaxrs2/Resteasy30RequestContextInstrumentation.java
dd-java-agent/instrumentation/jax-rs-annotations-2/filter-resteasy-3.0/src/main/java/datadog/trace/instrumentation/jaxrs2/Resteasy30RequestContextInstrumentation.java
@@ -15,7 +15,7 @@ public class Resteasy30RequestContextInstrumentation extends AbstractRequestCont
@Advice.OnMethodEnter(suppress = Throwable.class)
public static AgentScope decorateAbortSpan(@Advice.This final ContainerRequestContext context) {
- if (context.getProperty(ContainerRequestFilterInstrumentation.ABORT_HANDLED) == null
+ if (context.getProperty(JaxRsAnnotationsDecorator.ABORT_HANDLED) == null
&& context instanceof PostMatchContainerRequestContext) {
final ResourceMethodInvoker resourceMethodInvoker =

MODIFY
dd-java-agent/instrumentation/jax-rs-annotations-2/filter-resteasy-3.1/src/main/java/datadog/trace/instrumentation/jaxrs2/Resteasy31RequestContextInstrumentation.java
dd-java-agent/instrumentation/jax-rs-annotations-2/filter-resteasy-3.1/src/main/java/datadog/trace/instrumentation/jaxrs2/Resteasy31RequestContextInstrumentation.java
@@ -14,7 +14,7 @@ public class Resteasy31RequestContextInstrumentation extends AbstractRequestCont
public static class ContainerRequestContextAdvice {
@Advice.OnMethodEnter(suppress = Throwable.class)
public static AgentScope decorateAbortSpan(@Advice.This final ContainerRequestContext context) {
- if (context.getProperty(ContainerRequestFilterInstrumentation.ABORT_HANDLED) == null
+ if (context.getProperty(JaxRsAnnotationsDecorator.ABORT_HANDLED) == null
&& context instanceof PostMatchContainerRequestContext) {
final ResourceMethodInvoker resourceMethodInvoker =

MODIFY
dd-java-agent/instrumentation/jax-rs-annotations-2/src/main/java/datadog/trace/instrumentation/jaxrs2/AbstractRequestContextInstrumentation.java
dd-java-agent/instrumentation/jax-rs-annotations-2/src/main/java/datadog/trace/instrumentation/jaxrs2/AbstractRequestContextInstrumentation.java
@@ -60,14 +60,12 @@ public abstract class AbstractRequestContextInstrumentation extends Instrumenter
final ContainerRequestContext context, final Class resourceClass, final Method method) {
if (method != null && resourceClass != null) {
- context.setProperty(ContainerRequestFilterInstrumentation.ABORT_HANDLED, true);
+ context.setProperty(JaxRsAnnotationsDecorator.ABORT_HANDLED, true);
// The ordering of the specific and general abort instrumentation is unspecified
// The general instrumentation (ContainerRequestFilterInstrumentation) saves spans
// properties if it ran first
- AgentSpan parent =
- (AgentSpan) context.getProperty(ContainerRequestFilterInstrumentation.ABORT_PARENT);
- AgentSpan span =
- (AgentSpan) context.getProperty(ContainerRequestFilterInstrumentation.ABORT_SPAN);
+ AgentSpan parent = (AgentSpan) context.getProperty(JaxRsAnnotationsDecorator.ABORT_PARENT);
+ AgentSpan span = (AgentSpan) context.getProperty(JaxRsAnnotationsDecorator.ABORT_SPAN);
if (span == null) {
parent = activeSpan();

MODIFY
dd-java-agent/instrumentation/jax-rs-annotations-2/src/main/java/datadog/trace/instrumentation/jaxrs2/ContainerRequestFilterInstrumentation.java
dd-java-agent/instrumentation/jax-rs-annotations-2/src/main/java/datadog/trace/instrumentation/jaxrs2/ContainerRequestFilterInstrumentation.java
@@ -22,13 +22,6 @@ import net.bytebuddy.matcher.ElementMatcher;
/** This adds the filter class name to the request properties */
@AutoService(Instrumenter.class)
public class ContainerRequestFilterInstrumentation extends Instrumenter.Default {
- public static final String ABORT_FILTER_CLASS =
- "datadog.trace.instrumentation.jaxrs2.filter.abort.class";
- public static final String ABORT_HANDLED =
- "datadog.trace.instrumentation.jaxrs2.filter.abort.handled";
- public static final String ABORT_PARENT =
- "datadog.trace.instrumentation.jaxrs2.filter.abort.parent";
- public static final String ABORT_SPAN = "datadog.trace.instrumentation.jaxrs2.filter.abort.span";
public ContainerRequestFilterInstrumentation() {
super("jax-rs", "jaxrs", "jax-rs-filter");
@@ -55,7 +48,7 @@ public class ContainerRequestFilterInstrumentation extends Instrumenter.Default
public static void setFilterClass(
@Advice.This final ContainerRequestFilter filter,
@Advice.Argument(0) final ContainerRequestContext context) {
- context.setProperty(ABORT_FILTER_CLASS, filter.getClass());
+ context.setProperty(JaxRsAnnotationsDecorator.ABORT_FILTER_CLASS, filter.getClass());
}
}
}

MODIFY
dd-java-agent/instrumentation/jax-rs-annotations-2/src/main/java/datadog/trace/instrumentation/jaxrs2/DefaultRequestContextInstrumentation.java
dd-java-agent/instrumentation/jax-rs-annotations-2/src/main/java/datadog/trace/instrumentation/jaxrs2/DefaultRequestContextInstrumentation.java
@@ -23,16 +23,16 @@ public class DefaultRequestContextInstrumentation extends AbstractRequestContext
@Advice.OnMethodEnter(suppress = Throwable.class)
public static AgentScope createGenericSpan(@Advice.This final ContainerRequestContext context) {
- if (context.getProperty(ContainerRequestFilterInstrumentation.ABORT_HANDLED) == null) {
+ if (context.getProperty(JaxRsAnnotationsDecorator.ABORT_HANDLED) == null) {
final AgentSpan parent = activeSpan();
final AgentSpan span = startSpan("jax-rs.request.abort");
// Save spans so a more specific instrumentation can run later
- context.setProperty(ContainerRequestFilterInstrumentation.ABORT_PARENT, parent);
- context.setProperty(ContainerRequestFilterInstrumentation.ABORT_SPAN, span);
+ context.setProperty(JaxRsAnnotationsDecorator.ABORT_PARENT, parent);
+ context.setProperty(JaxRsAnnotationsDecorator.ABORT_SPAN, span);
final Class filterClass =
- (Class) context.getProperty(ContainerRequestFilterInstrumentation.ABORT_FILTER_CLASS);
+ (Class) context.getProperty(JaxRsAnnotationsDecorator.ABORT_FILTER_CLASS);
Method method = null;
try {
method = filterClass.getMethod("filter", ContainerRequestContext.class);

MODIFY
dd-java-agent/instrumentation/jax-rs-annotations-2/src/main/java/datadog/trace/instrumentation/jaxrs2/JaxRsAnnotationsDecorator.java
dd-java-agent/instrumentation/jax-rs-annotations-2/src/main/java/datadog/trace/instrumentation/jaxrs2/JaxRsAnnotationsDecorator.java
@@ -17,7 +17,15 @@ import javax.ws.rs.HttpMethod;
import javax.ws.rs.Path;
public class JaxRsAnnotationsDecorator extends BaseDecorator {
- public static JaxRsAnnotationsDecorator DECORATE = new JaxRsAnnotationsDecorator();
+ public static final String ABORT_FILTER_CLASS =
+ "datadog.trace.instrumentation.jaxrs2.filter.abort.class";
+ public static final String ABORT_HANDLED =
+ "datadog.trace.instrumentation.jaxrs2.filter.abort.handled";
+ public static final String ABORT_PARENT =
+ "datadog.trace.instrumentation.jaxrs2.filter.abort.parent";
+ public static final String ABORT_SPAN = "datadog.trace.instrumentation.jaxrs2.filter.abort.span";
+
+ public static final JaxRsAnnotationsDecorator DECORATE = new JaxRsAnnotationsDecorator();
private final WeakMap<Class, Map<Method, String>> resourceNames = newWeakMap();

Move constants to decorator