From 207f7706238cce1afbd3e13c09dd03079098bf06 Mon Sep 17 00:00:00 2001 From: Stuart McCulloch Date: Wed, 27 Nov 2024 19:32:42 +0000 Subject: [PATCH] Fix native-image generation of reactive applications (#8012) * Refactor registration of AsyncResult extensions so it doesn't pull in AsyncResultDecorator * Rebuild AsyncResultExtensions at native-image runtime --- .../decorator/AsyncResultDecorator.java | 97 ++----------------- .../java/concurrent/AsyncResultExtension.java | 27 ++++++ .../concurrent/AsyncResultExtensions.java | 67 +++++++++++++ ...veImageGeneratorRunnerInstrumentation.java | 1 + ...on.java => GuavaAsyncResultExtension.java} | 16 +-- .../ListenableFutureInstrumentation.java | 4 +- ...y => GuavaAsyncResultExtensionTest.groovy} | 2 +- .../PublisherInstrumentation.java | 10 +- ... ReactiveStreamsAsyncResultExtension.java} | 16 +-- ...iveStreamsAsyncResultExtensionTest.groovy} | 2 +- ...=> ReactorAsyncResultExtensionTest.groovy} | 2 +- .../BlockingPublisherInstrumentation.java | 4 +- ....java => ReactorAsyncResultExtension.java} | 16 +-- ...=> ReactorAsyncResultExtensionTest.groovy} | 2 +- ...n.java => RxJavaAsyncResultExtension.java} | 16 +-- .../rxjava2/RxJavaPluginsInstrumentation.java | 4 +- ...oovy => RxJava2ResultExtensionTest.groovy} | 2 +- 17 files changed, 152 insertions(+), 136 deletions(-) create mode 100644 dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/java/concurrent/AsyncResultExtension.java create mode 100644 dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/java/concurrent/AsyncResultExtensions.java rename dd-java-agent/instrumentation/guava-10/src/main/java/datadog/trace/instrumentation/guava10/{GuavaAsyncResultSupportExtension.java => GuavaAsyncResultExtension.java} (74%) rename dd-java-agent/instrumentation/guava-10/src/test/groovy/{GuavaAsyncResultSupportExtensionTest.groovy => GuavaAsyncResultExtensionTest.groovy} (97%) rename dd-java-agent/instrumentation/reactive-streams/src/main/java/datadog/trace/instrumentation/reactivestreams/{ReactiveStreamsAsyncResultSupportExtension.java => ReactiveStreamsAsyncResultExtension.java} (81%) rename dd-java-agent/instrumentation/reactive-streams/src/test/groovy/{ReactiveStreamsAsyncResultSupportExtensionTest.groovy => ReactiveStreamsAsyncResultExtensionTest.groovy} (97%) rename dd-java-agent/instrumentation/reactor-core-3.1/src/latestDepTest/groovy/{ReactorAsyncResultSupportExtensionTest.groovy => ReactorAsyncResultExtensionTest.groovy} (98%) rename dd-java-agent/instrumentation/reactor-core-3.1/src/main/java/datadog/trace/instrumentation/reactor/core/{ReactorAsyncResultSupportExtension.java => ReactorAsyncResultExtension.java} (64%) rename dd-java-agent/instrumentation/reactor-core-3.1/src/test/groovy/{ReactorAsyncResultSupportExtensionTest.groovy => ReactorAsyncResultExtensionTest.groovy} (98%) rename dd-java-agent/instrumentation/rxjava-2/src/main/java/datadog/trace/instrumentation/rxjava2/{RxJavaAsyncResultSupportExtension.java => RxJavaAsyncResultExtension.java} (80%) rename dd-java-agent/instrumentation/rxjava-2/src/test/groovy/{RxJava2ResultSupportExtensionTest.groovy => RxJava2ResultExtensionTest.groovy} (97%) diff --git a/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/AsyncResultDecorator.java b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/AsyncResultDecorator.java index ececbdfc8ae..fdcf7c60f74 100644 --- a/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/AsyncResultDecorator.java +++ b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/AsyncResultDecorator.java @@ -1,47 +1,27 @@ package datadog.trace.bootstrap.instrumentation.decorator; -import static java.util.Collections.singletonList; - import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionException; -import java.util.concurrent.CompletionStage; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.ExecutionException; -import java.util.function.BiConsumer; +import datadog.trace.bootstrap.instrumentation.java.concurrent.AsyncResultExtension; +import datadog.trace.bootstrap.instrumentation.java.concurrent.AsyncResultExtensions; /** * This decorator handles asynchronous result types, finishing spans only when the async calls are - * complete. The different async types are supported using {@link AsyncResultSupportExtension} that - * should be registered using {@link #registerExtension(AsyncResultSupportExtension)} first. + * complete. The different async types are supported using {@link AsyncResultExtension} that should + * be registered using {@link AsyncResultExtensions#register(AsyncResultExtension)} first. */ public abstract class AsyncResultDecorator extends BaseDecorator { - private static final CopyOnWriteArrayList EXTENSIONS = - new CopyOnWriteArrayList<>( - singletonList(new JavaUtilConcurrentAsyncResultSupportExtension())); - private static final ClassValue EXTENSION_CLASS_VALUE = - new ClassValue() { + private static final ClassValue EXTENSION_CLASS_VALUE = + new ClassValue() { @Override - protected AsyncResultSupportExtension computeValue(Class type) { - return EXTENSIONS.stream() + protected AsyncResultExtension computeValue(Class type) { + return AsyncResultExtensions.registered().stream() .filter(extension -> extension.supports(type)) .findFirst() .orElse(null); } }; - /** - * Registers an extension to add supported async types. - * - * @param extension The extension to register. - */ - public static void registerExtension(AsyncResultSupportExtension extension) { - if (extension != null) { - EXTENSIONS.add(extension); - } - } - /** * Look for asynchronous result and decorate it with span finisher. If the result is not * asynchronous, it will be return unmodified and span will be finished. @@ -53,7 +33,7 @@ public static void registerExtension(AsyncResultSupportExtension extension) { */ public Object wrapAsyncResultOrFinishSpan( final Object result, final Class methodReturnType, final AgentSpan span) { - AsyncResultSupportExtension extension; + AsyncResultExtension extension; if (result != null && (extension = EXTENSION_CLASS_VALUE.get(methodReturnType)) != null) { Object applied = extension.apply(result, span); if (applied != null) { @@ -64,63 +44,4 @@ public Object wrapAsyncResultOrFinishSpan( span.finish(); return result; } - - /** - * This interface defines asynchronous result type support extension. It allows deferring the - * support implementations where types are available on classpath. - */ - public interface AsyncResultSupportExtension { - /** - * Checks whether this extensions support a result type. - * - * @param result The result type to check. - * @return {@code true} if the type is supported by this extension, {@code false} otherwise. - */ - boolean supports(Class result); - - /** - * Applies the extension to the async result. - * - * @param result The async result. - * @param span The related span. - * @return The result object to return (can be the original result if not modified), or {@code - * null} if the extension could not be applied. - */ - Object apply(Object result, AgentSpan span); - } - - private static class JavaUtilConcurrentAsyncResultSupportExtension - implements AsyncResultSupportExtension { - @Override - public boolean supports(Class result) { - return CompletableFuture.class.isAssignableFrom(result) - || CompletionStage.class.isAssignableFrom(result); - } - - @Override - public Object apply(Object result, AgentSpan span) { - if (result instanceof CompletableFuture) { - CompletableFuture completableFuture = (CompletableFuture) result; - if (!completableFuture.isDone() && !completableFuture.isCancelled()) { - return completableFuture.whenComplete(finishSpan(span)); - } - } else if (result instanceof CompletionStage) { - CompletionStage completionStage = (CompletionStage) result; - return completionStage.whenComplete(finishSpan(span)); - } - return null; - } - - private BiConsumer finishSpan(AgentSpan span) { - return (o, throwable) -> { - if (throwable != null) { - span.addThrowable( - throwable instanceof ExecutionException || throwable instanceof CompletionException - ? throwable.getCause() - : throwable); - } - span.finish(); - }; - } - } } diff --git a/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/java/concurrent/AsyncResultExtension.java b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/java/concurrent/AsyncResultExtension.java new file mode 100644 index 00000000000..07d8fed551e --- /dev/null +++ b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/java/concurrent/AsyncResultExtension.java @@ -0,0 +1,27 @@ +package datadog.trace.bootstrap.instrumentation.java.concurrent; + +import datadog.trace.bootstrap.instrumentation.api.AgentSpan; + +/** + * This interface defines asynchronous result type support extension. It allows deferring the + * support implementations where types are available on classpath. + */ +public interface AsyncResultExtension { + /** + * Checks whether this extensions support a result type. + * + * @param result The result type to check. + * @return {@code true} if the type is supported by this extension, {@code false} otherwise. + */ + boolean supports(Class result); + + /** + * Applies the extension to the async result. + * + * @param result The async result. + * @param span The related span. + * @return The result object to return (can be the original result if not modified), or {@code + * null} if the extension could not be applied. + */ + Object apply(Object result, AgentSpan span); +} diff --git a/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/java/concurrent/AsyncResultExtensions.java b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/java/concurrent/AsyncResultExtensions.java new file mode 100644 index 00000000000..7e54f058753 --- /dev/null +++ b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/java/concurrent/AsyncResultExtensions.java @@ -0,0 +1,67 @@ +package datadog.trace.bootstrap.instrumentation.java.concurrent; + +import static java.util.Collections.singletonList; + +import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; +import java.util.concurrent.CompletionStage; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.ExecutionException; +import java.util.function.BiConsumer; + +public final class AsyncResultExtensions { + private static final List EXTENSIONS = + new CopyOnWriteArrayList<>(singletonList(new CompletableAsyncResultExtension())); + + /** + * Registers an extension to add supported async types. + * + * @param extension The extension to register. + */ + public static void register(AsyncResultExtension extension) { + if (extension != null) { + EXTENSIONS.add(extension); + } + } + + /** Returns the list of currently registered extensions. */ + public static List registered() { + return EXTENSIONS; + } + + static final class CompletableAsyncResultExtension implements AsyncResultExtension { + @Override + public boolean supports(Class result) { + return CompletableFuture.class.isAssignableFrom(result) + || CompletionStage.class.isAssignableFrom(result); + } + + @Override + public Object apply(Object result, AgentSpan span) { + if (result instanceof CompletableFuture) { + CompletableFuture completableFuture = (CompletableFuture) result; + if (!completableFuture.isDone() && !completableFuture.isCancelled()) { + return completableFuture.whenComplete(finishSpan(span)); + } + } else if (result instanceof CompletionStage) { + CompletionStage completionStage = (CompletionStage) result; + return completionStage.whenComplete(finishSpan(span)); + } + return null; + } + + private BiConsumer finishSpan(AgentSpan span) { + return (o, throwable) -> { + if (throwable != null) { + span.addThrowable( + throwable instanceof ExecutionException || throwable instanceof CompletionException + ? throwable.getCause() + : throwable); + } + span.finish(); + }; + } + } +} diff --git a/dd-java-agent/instrumentation/graal/native-image/src/main/java/datadog/trace/instrumentation/graal/nativeimage/NativeImageGeneratorRunnerInstrumentation.java b/dd-java-agent/instrumentation/graal/native-image/src/main/java/datadog/trace/instrumentation/graal/nativeimage/NativeImageGeneratorRunnerInstrumentation.java index ebfef8bb62c..9b24b9d3fca 100644 --- a/dd-java-agent/instrumentation/graal/native-image/src/main/java/datadog/trace/instrumentation/graal/nativeimage/NativeImageGeneratorRunnerInstrumentation.java +++ b/dd-java-agent/instrumentation/graal/native-image/src/main/java/datadog/trace/instrumentation/graal/nativeimage/NativeImageGeneratorRunnerInstrumentation.java @@ -96,6 +96,7 @@ public static void onEnter(@Advice.Argument(value = 0, readOnly = false) String[ + "datadog.trace.bootstrap.benchmark.StaticEventLogger:build_time," + "datadog.trace.bootstrap.blocking.BlockingExceptionHandler:build_time," + "datadog.trace.bootstrap.InstrumentationErrors:build_time," + + "datadog.trace.bootstrap.instrumentation.java.concurrent.AsyncResultExtensions:rerun," + "datadog.trace.bootstrap.instrumentation.java.concurrent.ConcurrentState:build_time," + "datadog.trace.bootstrap.instrumentation.java.concurrent.ExcludeFilter:build_time," + "datadog.trace.bootstrap.instrumentation.java.concurrent.QueueTimeHelper:build_time," diff --git a/dd-java-agent/instrumentation/guava-10/src/main/java/datadog/trace/instrumentation/guava10/GuavaAsyncResultSupportExtension.java b/dd-java-agent/instrumentation/guava-10/src/main/java/datadog/trace/instrumentation/guava10/GuavaAsyncResultExtension.java similarity index 74% rename from dd-java-agent/instrumentation/guava-10/src/main/java/datadog/trace/instrumentation/guava10/GuavaAsyncResultSupportExtension.java rename to dd-java-agent/instrumentation/guava-10/src/main/java/datadog/trace/instrumentation/guava10/GuavaAsyncResultExtension.java index 7d79fe052bc..5a0788e3642 100644 --- a/dd-java-agent/instrumentation/guava-10/src/main/java/datadog/trace/instrumentation/guava10/GuavaAsyncResultSupportExtension.java +++ b/dd-java-agent/instrumentation/guava-10/src/main/java/datadog/trace/instrumentation/guava10/GuavaAsyncResultExtension.java @@ -2,22 +2,22 @@ import com.google.common.util.concurrent.ListenableFuture; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import datadog.trace.bootstrap.instrumentation.decorator.AsyncResultDecorator; +import datadog.trace.bootstrap.instrumentation.java.concurrent.AsyncResultExtension; +import datadog.trace.bootstrap.instrumentation.java.concurrent.AsyncResultExtensions; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; -public class GuavaAsyncResultSupportExtension - implements AsyncResultDecorator.AsyncResultSupportExtension { +public class GuavaAsyncResultExtension implements AsyncResultExtension { static { - AsyncResultDecorator.registerExtension(new GuavaAsyncResultSupportExtension()); + AsyncResultExtensions.register(new GuavaAsyncResultExtension()); } /** - * Register the extension as an {@link AsyncResultDecorator.AsyncResultSupportExtension} using - * static class initialization.
+ * Register the extension as an {@link AsyncResultExtension} using static class initialization. + *
* It uses an empty static method call to ensure the class loading and the one-time-only static - * class initialization. This will ensure this extension will only be registered once to the - * {@link AsyncResultDecorator}. + * class initialization. This will ensure this extension will only be registered once under {@link + * AsyncResultExtensions}. */ public static void initialize() {} diff --git a/dd-java-agent/instrumentation/guava-10/src/main/java/datadog/trace/instrumentation/guava10/ListenableFutureInstrumentation.java b/dd-java-agent/instrumentation/guava-10/src/main/java/datadog/trace/instrumentation/guava10/ListenableFutureInstrumentation.java index cf8f6c4b5ec..76811786110 100644 --- a/dd-java-agent/instrumentation/guava-10/src/main/java/datadog/trace/instrumentation/guava10/ListenableFutureInstrumentation.java +++ b/dd-java-agent/instrumentation/guava-10/src/main/java/datadog/trace/instrumentation/guava10/ListenableFutureInstrumentation.java @@ -36,7 +36,7 @@ public String instrumentedType() { @Override public String[] helperClassNames() { return new String[] { - this.packageName + ".GuavaAsyncResultSupportExtension", + this.packageName + ".GuavaAsyncResultExtension", }; } @@ -57,7 +57,7 @@ public void methodAdvice(MethodTransformer transformer) { public static class AbstractFutureAdvice { @Advice.OnMethodExit(suppress = Throwable.class) public static void init() { - GuavaAsyncResultSupportExtension.initialize(); + GuavaAsyncResultExtension.initialize(); } } diff --git a/dd-java-agent/instrumentation/guava-10/src/test/groovy/GuavaAsyncResultSupportExtensionTest.groovy b/dd-java-agent/instrumentation/guava-10/src/test/groovy/GuavaAsyncResultExtensionTest.groovy similarity index 97% rename from dd-java-agent/instrumentation/guava-10/src/test/groovy/GuavaAsyncResultSupportExtensionTest.groovy rename to dd-java-agent/instrumentation/guava-10/src/test/groovy/GuavaAsyncResultExtensionTest.groovy index 38c44289538..1e60dc956f9 100644 --- a/dd-java-agent/instrumentation/guava-10/src/test/groovy/GuavaAsyncResultSupportExtensionTest.groovy +++ b/dd-java-agent/instrumentation/guava-10/src/test/groovy/GuavaAsyncResultExtensionTest.groovy @@ -8,7 +8,7 @@ import java.util.concurrent.ExecutionException import java.util.concurrent.ExecutorService import java.util.concurrent.Executors -class GuavaAsyncResultSupportExtensionTest extends AgentTestRunner { +class GuavaAsyncResultExtensionTest extends AgentTestRunner { @Override void configurePreAgent() { super.configurePreAgent() diff --git a/dd-java-agent/instrumentation/reactive-streams/src/main/java/datadog/trace/instrumentation/reactivestreams/PublisherInstrumentation.java b/dd-java-agent/instrumentation/reactive-streams/src/main/java/datadog/trace/instrumentation/reactivestreams/PublisherInstrumentation.java index 5acc5e79d1d..f6782955ad2 100644 --- a/dd-java-agent/instrumentation/reactive-streams/src/main/java/datadog/trace/instrumentation/reactivestreams/PublisherInstrumentation.java +++ b/dd-java-agent/instrumentation/reactive-streams/src/main/java/datadog/trace/instrumentation/reactivestreams/PublisherInstrumentation.java @@ -60,10 +60,10 @@ public Map contextStore() { @Override public String[] helperClassNames() { return new String[] { - this.packageName + ".ReactiveStreamsAsyncResultSupportExtension", - this.packageName + ".ReactiveStreamsAsyncResultSupportExtension$WrappedPublisher", - this.packageName + ".ReactiveStreamsAsyncResultSupportExtension$WrappedSubscriber", - this.packageName + ".ReactiveStreamsAsyncResultSupportExtension$WrappedSubscription", + this.packageName + ".ReactiveStreamsAsyncResultExtension", + this.packageName + ".ReactiveStreamsAsyncResultExtension$WrappedPublisher", + this.packageName + ".ReactiveStreamsAsyncResultExtension$WrappedSubscriber", + this.packageName + ".ReactiveStreamsAsyncResultExtension$WrappedSubscription", }; } @@ -82,7 +82,7 @@ public void methodAdvice(MethodTransformer transformer) { public static class PublisherAdvice { @Advice.OnMethodExit(suppress = Throwable.class) public static void init() { - ReactiveStreamsAsyncResultSupportExtension.initialize(); + ReactiveStreamsAsyncResultExtension.initialize(); } } diff --git a/dd-java-agent/instrumentation/reactive-streams/src/main/java/datadog/trace/instrumentation/reactivestreams/ReactiveStreamsAsyncResultSupportExtension.java b/dd-java-agent/instrumentation/reactive-streams/src/main/java/datadog/trace/instrumentation/reactivestreams/ReactiveStreamsAsyncResultExtension.java similarity index 81% rename from dd-java-agent/instrumentation/reactive-streams/src/main/java/datadog/trace/instrumentation/reactivestreams/ReactiveStreamsAsyncResultSupportExtension.java rename to dd-java-agent/instrumentation/reactive-streams/src/main/java/datadog/trace/instrumentation/reactivestreams/ReactiveStreamsAsyncResultExtension.java index 66b3de15490..666f63dad1d 100644 --- a/dd-java-agent/instrumentation/reactive-streams/src/main/java/datadog/trace/instrumentation/reactivestreams/ReactiveStreamsAsyncResultSupportExtension.java +++ b/dd-java-agent/instrumentation/reactive-streams/src/main/java/datadog/trace/instrumentation/reactivestreams/ReactiveStreamsAsyncResultExtension.java @@ -1,23 +1,23 @@ package datadog.trace.instrumentation.reactivestreams; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import datadog.trace.bootstrap.instrumentation.decorator.AsyncResultDecorator; -import datadog.trace.bootstrap.instrumentation.decorator.AsyncResultDecorator.AsyncResultSupportExtension; +import datadog.trace.bootstrap.instrumentation.java.concurrent.AsyncResultExtension; +import datadog.trace.bootstrap.instrumentation.java.concurrent.AsyncResultExtensions; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; -public class ReactiveStreamsAsyncResultSupportExtension implements AsyncResultSupportExtension { +public class ReactiveStreamsAsyncResultExtension implements AsyncResultExtension { static { - AsyncResultDecorator.registerExtension(new ReactiveStreamsAsyncResultSupportExtension()); + AsyncResultExtensions.register(new ReactiveStreamsAsyncResultExtension()); } /** - * Register the extension as an {@link AsyncResultSupportExtension} using static class - * initialization.
+ * Register the extension as an {@link AsyncResultExtension} using static class initialization. + *
* It uses an empty static method call to ensure the class loading and the one-time-only static - * class initialization. This will ensure this extension will only be registered once to the - * {@link AsyncResultDecorator}. + * class initialization. This will ensure this extension will only be registered once under {@link + * AsyncResultExtensions}. */ public static void initialize() {} diff --git a/dd-java-agent/instrumentation/reactive-streams/src/test/groovy/ReactiveStreamsAsyncResultSupportExtensionTest.groovy b/dd-java-agent/instrumentation/reactive-streams/src/test/groovy/ReactiveStreamsAsyncResultExtensionTest.groovy similarity index 97% rename from dd-java-agent/instrumentation/reactive-streams/src/test/groovy/ReactiveStreamsAsyncResultSupportExtensionTest.groovy rename to dd-java-agent/instrumentation/reactive-streams/src/test/groovy/ReactiveStreamsAsyncResultExtensionTest.groovy index 8f605df6e18..2f179aae07a 100644 --- a/dd-java-agent/instrumentation/reactive-streams/src/test/groovy/ReactiveStreamsAsyncResultSupportExtensionTest.groovy +++ b/dd-java-agent/instrumentation/reactive-streams/src/test/groovy/ReactiveStreamsAsyncResultExtensionTest.groovy @@ -4,7 +4,7 @@ import datadog.trace.bootstrap.instrumentation.api.Tags import java.util.concurrent.CountDownLatch -class ReactiveStreamsAsyncResultSupportExtensionTest extends AgentTestRunner { +class ReactiveStreamsAsyncResultExtensionTest extends AgentTestRunner { @Override void configurePreAgent() { super.configurePreAgent() diff --git a/dd-java-agent/instrumentation/reactor-core-3.1/src/latestDepTest/groovy/ReactorAsyncResultSupportExtensionTest.groovy b/dd-java-agent/instrumentation/reactor-core-3.1/src/latestDepTest/groovy/ReactorAsyncResultExtensionTest.groovy similarity index 98% rename from dd-java-agent/instrumentation/reactor-core-3.1/src/latestDepTest/groovy/ReactorAsyncResultSupportExtensionTest.groovy rename to dd-java-agent/instrumentation/reactor-core-3.1/src/latestDepTest/groovy/ReactorAsyncResultExtensionTest.groovy index a80e5564117..4e9c08c9245 100644 --- a/dd-java-agent/instrumentation/reactor-core-3.1/src/latestDepTest/groovy/ReactorAsyncResultSupportExtensionTest.groovy +++ b/dd-java-agent/instrumentation/reactor-core-3.1/src/latestDepTest/groovy/ReactorAsyncResultExtensionTest.groovy @@ -8,7 +8,7 @@ import spock.lang.Shared import java.util.concurrent.CountDownLatch import java.util.concurrent.Executors -class ReactorAsyncResultSupportExtensionTest extends AgentTestRunner { +class ReactorAsyncResultExtensionTest extends AgentTestRunner { @Override void configurePreAgent() { super.configurePreAgent() diff --git a/dd-java-agent/instrumentation/reactor-core-3.1/src/main/java/datadog/trace/instrumentation/reactor/core/BlockingPublisherInstrumentation.java b/dd-java-agent/instrumentation/reactor-core-3.1/src/main/java/datadog/trace/instrumentation/reactor/core/BlockingPublisherInstrumentation.java index 2e61d85ec79..69b60923a71 100644 --- a/dd-java-agent/instrumentation/reactor-core-3.1/src/main/java/datadog/trace/instrumentation/reactor/core/BlockingPublisherInstrumentation.java +++ b/dd-java-agent/instrumentation/reactor-core-3.1/src/main/java/datadog/trace/instrumentation/reactor/core/BlockingPublisherInstrumentation.java @@ -36,7 +36,7 @@ public BlockingPublisherInstrumentation() { @Override public String[] helperClassNames() { return new String[] { - packageName + ".ReactorAsyncResultSupportExtension", + packageName + ".ReactorAsyncResultExtension", }; } @@ -83,7 +83,7 @@ public static void after(@Advice.Enter final AgentScope scope) { public static class AsyncExtensionInstallAdvice { @Advice.OnMethodExit(suppress = Throwable.class) public static void init() { - ReactorAsyncResultSupportExtension.initialize(); + ReactorAsyncResultExtension.initialize(); } } } diff --git a/dd-java-agent/instrumentation/reactor-core-3.1/src/main/java/datadog/trace/instrumentation/reactor/core/ReactorAsyncResultSupportExtension.java b/dd-java-agent/instrumentation/reactor-core-3.1/src/main/java/datadog/trace/instrumentation/reactor/core/ReactorAsyncResultExtension.java similarity index 64% rename from dd-java-agent/instrumentation/reactor-core-3.1/src/main/java/datadog/trace/instrumentation/reactor/core/ReactorAsyncResultSupportExtension.java rename to dd-java-agent/instrumentation/reactor-core-3.1/src/main/java/datadog/trace/instrumentation/reactor/core/ReactorAsyncResultExtension.java index d180541a274..09f586a14ee 100644 --- a/dd-java-agent/instrumentation/reactor-core-3.1/src/main/java/datadog/trace/instrumentation/reactor/core/ReactorAsyncResultSupportExtension.java +++ b/dd-java-agent/instrumentation/reactor-core-3.1/src/main/java/datadog/trace/instrumentation/reactor/core/ReactorAsyncResultExtension.java @@ -1,22 +1,22 @@ package datadog.trace.instrumentation.reactor.core; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import datadog.trace.bootstrap.instrumentation.decorator.AsyncResultDecorator; -import datadog.trace.bootstrap.instrumentation.decorator.AsyncResultDecorator.AsyncResultSupportExtension; +import datadog.trace.bootstrap.instrumentation.java.concurrent.AsyncResultExtension; +import datadog.trace.bootstrap.instrumentation.java.concurrent.AsyncResultExtensions; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -public class ReactorAsyncResultSupportExtension implements AsyncResultSupportExtension { +public class ReactorAsyncResultExtension implements AsyncResultExtension { static { - AsyncResultDecorator.registerExtension(new ReactorAsyncResultSupportExtension()); + AsyncResultExtensions.register(new ReactorAsyncResultExtension()); } /** - * Register the extension as an {@link AsyncResultSupportExtension} using static class - * initialization.
+ * Register the extension as an {@link AsyncResultExtension} using static class initialization. + *
* It uses an empty static method call to ensure the class loading and the one-time-only static - * class initialization. This will ensure this extension will only be registered once to the - * {@link AsyncResultDecorator}. + * class initialization. This will ensure this extension will only be registered once under {@link + * AsyncResultExtensions}. */ public static void initialize() {} diff --git a/dd-java-agent/instrumentation/reactor-core-3.1/src/test/groovy/ReactorAsyncResultSupportExtensionTest.groovy b/dd-java-agent/instrumentation/reactor-core-3.1/src/test/groovy/ReactorAsyncResultExtensionTest.groovy similarity index 98% rename from dd-java-agent/instrumentation/reactor-core-3.1/src/test/groovy/ReactorAsyncResultSupportExtensionTest.groovy rename to dd-java-agent/instrumentation/reactor-core-3.1/src/test/groovy/ReactorAsyncResultExtensionTest.groovy index 94a82f4a25b..1f4a2de5443 100644 --- a/dd-java-agent/instrumentation/reactor-core-3.1/src/test/groovy/ReactorAsyncResultSupportExtensionTest.groovy +++ b/dd-java-agent/instrumentation/reactor-core-3.1/src/test/groovy/ReactorAsyncResultExtensionTest.groovy @@ -8,7 +8,7 @@ import spock.lang.Shared import java.util.concurrent.CountDownLatch import java.util.concurrent.Executors -class ReactorAsyncResultSupportExtensionTest extends AgentTestRunner { +class ReactorAsyncResultExtensionTest extends AgentTestRunner { @Override void configurePreAgent() { super.configurePreAgent() diff --git a/dd-java-agent/instrumentation/rxjava-2/src/main/java/datadog/trace/instrumentation/rxjava2/RxJavaAsyncResultSupportExtension.java b/dd-java-agent/instrumentation/rxjava-2/src/main/java/datadog/trace/instrumentation/rxjava2/RxJavaAsyncResultExtension.java similarity index 80% rename from dd-java-agent/instrumentation/rxjava-2/src/main/java/datadog/trace/instrumentation/rxjava2/RxJavaAsyncResultSupportExtension.java rename to dd-java-agent/instrumentation/rxjava-2/src/main/java/datadog/trace/instrumentation/rxjava2/RxJavaAsyncResultExtension.java index e77536bc192..44ca7c5d6c9 100644 --- a/dd-java-agent/instrumentation/rxjava-2/src/main/java/datadog/trace/instrumentation/rxjava2/RxJavaAsyncResultSupportExtension.java +++ b/dd-java-agent/instrumentation/rxjava-2/src/main/java/datadog/trace/instrumentation/rxjava2/RxJavaAsyncResultExtension.java @@ -1,25 +1,25 @@ package datadog.trace.instrumentation.rxjava2; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import datadog.trace.bootstrap.instrumentation.decorator.AsyncResultDecorator; +import datadog.trace.bootstrap.instrumentation.java.concurrent.AsyncResultExtension; +import datadog.trace.bootstrap.instrumentation.java.concurrent.AsyncResultExtensions; import io.reactivex.Completable; import io.reactivex.Flowable; import io.reactivex.Maybe; import io.reactivex.Observable; import io.reactivex.Single; -public class RxJavaAsyncResultSupportExtension - implements AsyncResultDecorator.AsyncResultSupportExtension { +public class RxJavaAsyncResultExtension implements AsyncResultExtension { static { - AsyncResultDecorator.registerExtension(new RxJavaAsyncResultSupportExtension()); + AsyncResultExtensions.register(new RxJavaAsyncResultExtension()); } /** - * Register the extension as an {@link AsyncResultDecorator.AsyncResultSupportExtension} using - * static class initialization.
+ * Register the extension as an {@link AsyncResultExtension} using static class initialization. + *
* It uses an empty static method call to ensure the class loading and the one-time-only static - * class initialization. This will ensure this extension will only be registered once to the - * {@link AsyncResultDecorator}. + * class initialization. This will ensure this extension will only be registered once under {@link + * AsyncResultExtensions}. */ public static void initialize() {} diff --git a/dd-java-agent/instrumentation/rxjava-2/src/main/java/datadog/trace/instrumentation/rxjava2/RxJavaPluginsInstrumentation.java b/dd-java-agent/instrumentation/rxjava-2/src/main/java/datadog/trace/instrumentation/rxjava2/RxJavaPluginsInstrumentation.java index 0140c345727..5772ab71acf 100644 --- a/dd-java-agent/instrumentation/rxjava-2/src/main/java/datadog/trace/instrumentation/rxjava2/RxJavaPluginsInstrumentation.java +++ b/dd-java-agent/instrumentation/rxjava-2/src/main/java/datadog/trace/instrumentation/rxjava2/RxJavaPluginsInstrumentation.java @@ -30,7 +30,7 @@ public String instrumentedType() { @Override public String[] helperClassNames() { return new String[] { - packageName + ".RxJavaAsyncResultSupportExtension", + packageName + ".RxJavaAsyncResultExtension", }; } @@ -42,7 +42,7 @@ public void methodAdvice(MethodTransformer transformer) { public static class RxJavaPluginsAdvice { @Advice.OnMethodExit(suppress = Throwable.class) public static void init() { - RxJavaAsyncResultSupportExtension.initialize(); + RxJavaAsyncResultExtension.initialize(); } } } diff --git a/dd-java-agent/instrumentation/rxjava-2/src/test/groovy/RxJava2ResultSupportExtensionTest.groovy b/dd-java-agent/instrumentation/rxjava-2/src/test/groovy/RxJava2ResultExtensionTest.groovy similarity index 97% rename from dd-java-agent/instrumentation/rxjava-2/src/test/groovy/RxJava2ResultSupportExtensionTest.groovy rename to dd-java-agent/instrumentation/rxjava-2/src/test/groovy/RxJava2ResultExtensionTest.groovy index c3fd5e92dce..9ff97597138 100644 --- a/dd-java-agent/instrumentation/rxjava-2/src/test/groovy/RxJava2ResultSupportExtensionTest.groovy +++ b/dd-java-agent/instrumentation/rxjava-2/src/test/groovy/RxJava2ResultExtensionTest.groovy @@ -4,7 +4,7 @@ import datadog.trace.bootstrap.instrumentation.api.Tags import java.util.concurrent.CountDownLatch -class RxJava2ResultSupportExtensionTest extends AgentTestRunner { +class RxJava2ResultExtensionTest extends AgentTestRunner { @Override void configurePreAgent() { super.configurePreAgent()