From 7022f10b81ce4fd988f03d82a472bc05e8b63d61 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sat, 29 Aug 2020 22:06:13 -0700 Subject: [PATCH] Remove unused code (#1128) --- .../ExecutorInstrumentationUtils.java | 11 ++----- .../AkkaExecutorInstrumentation.java | 8 ++--- .../JavaExecutorInstrumentation.java | 31 ++++--------------- .../ScalaExecutorInstrumentation.java | 8 ++--- 4 files changed, 12 insertions(+), 46 deletions(-) diff --git a/auto-api/src/main/java/io/opentelemetry/instrumentation/auto/api/concurrent/ExecutorInstrumentationUtils.java b/auto-api/src/main/java/io/opentelemetry/instrumentation/auto/api/concurrent/ExecutorInstrumentationUtils.java index 610a250bd0..400717d36f 100644 --- a/auto-api/src/main/java/io/opentelemetry/instrumentation/auto/api/concurrent/ExecutorInstrumentationUtils.java +++ b/auto-api/src/main/java/io/opentelemetry/instrumentation/auto/api/concurrent/ExecutorInstrumentationUtils.java @@ -24,23 +24,17 @@ import io.opentelemetry.instrumentation.auto.api.ContextStore; import io.opentelemetry.trace.Span; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.Executor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** Utils for concurrent instrumentations. */ public class ExecutorInstrumentationUtils { - private static final Logger log = LoggerFactory.getLogger(ExecutorInstrumentationUtils.class); - /** * Checks if given task should get state attached. * * @param task task object - * @param executor executor this task was scheduled on * @return true iff given task object should be wrapped */ - public static boolean shouldAttachStateToTask(Object task, Executor executor) { + public static boolean shouldAttachStateToTask(Object task) { if (task == null) { return false; } @@ -54,8 +48,7 @@ public class ExecutorInstrumentationUtils { // https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/787 && !taskClass.getName().equals("org.apache.tomcat.util.net.NioEndpoint$SocketProcessor") // Don't instrument the executor's own runnables. These runnables may never return until - // netty shuts down. Any created continuations will be open until that time preventing - // traces from being reported + // netty shuts down. && (enclosingClass == null || !enclosingClass .getName() diff --git a/instrumentation/akka-context-propagation-2.5/src/main/java/io/opentelemetry/instrumentation/auto/akkaconcurrent/AkkaExecutorInstrumentation.java b/instrumentation/akka-context-propagation-2.5/src/main/java/io/opentelemetry/instrumentation/auto/akkaconcurrent/AkkaExecutorInstrumentation.java index 6016902220..830b72773c 100644 --- a/instrumentation/akka-context-propagation-2.5/src/main/java/io/opentelemetry/instrumentation/auto/akkaconcurrent/AkkaExecutorInstrumentation.java +++ b/instrumentation/akka-context-propagation-2.5/src/main/java/io/opentelemetry/instrumentation/auto/akkaconcurrent/AkkaExecutorInstrumentation.java @@ -32,7 +32,6 @@ import io.opentelemetry.instrumentation.auto.javaconcurrent.AbstractExecutorInst import io.opentelemetry.javaagent.tooling.Instrumenter; import java.util.HashMap; import java.util.Map; -import java.util.concurrent.Executor; import net.bytebuddy.asm.Advice; import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.matcher.ElementMatcher; @@ -76,9 +75,8 @@ public final class AkkaExecutorInstrumentation extends AbstractExecutorInstrumen @Advice.OnMethodEnter(suppress = Throwable.class) public static State enterJobSubmit( - @Advice.This Executor executor, @Advice.Argument(value = 0, readOnly = false) ForkJoinTask task) { - if (ExecutorInstrumentationUtils.shouldAttachStateToTask(task, executor)) { + if (ExecutorInstrumentationUtils.shouldAttachStateToTask(task)) { ContextStore contextStore = InstrumentationContext.get(ForkJoinTask.class, State.class); return ExecutorInstrumentationUtils.setupState(contextStore, task, Context.current()); @@ -88,9 +86,7 @@ public final class AkkaExecutorInstrumentation extends AbstractExecutorInstrumen @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) public static void exitJobSubmit( - @Advice.This Executor executor, - @Advice.Enter State state, - @Advice.Thrown Throwable throwable) { + @Advice.Enter State state, @Advice.Thrown Throwable throwable) { ExecutorInstrumentationUtils.cleanUpOnMethodExit(state, throwable); } } diff --git a/instrumentation/java-concurrent/src/main/java/io/opentelemetry/instrumentation/auto/javaconcurrent/JavaExecutorInstrumentation.java b/instrumentation/java-concurrent/src/main/java/io/opentelemetry/instrumentation/auto/javaconcurrent/JavaExecutorInstrumentation.java index d14a8b709d..efb2ad76d4 100644 --- a/instrumentation/java-concurrent/src/main/java/io/opentelemetry/instrumentation/auto/javaconcurrent/JavaExecutorInstrumentation.java +++ b/instrumentation/java-concurrent/src/main/java/io/opentelemetry/instrumentation/auto/javaconcurrent/JavaExecutorInstrumentation.java @@ -36,7 +36,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.concurrent.Callable; -import java.util.concurrent.Executor; import java.util.concurrent.ForkJoinTask; import java.util.concurrent.Future; import net.bytebuddy.asm.Advice; @@ -94,12 +93,9 @@ public final class JavaExecutorInstrumentation extends AbstractExecutorInstrumen @Advice.OnMethodEnter(suppress = Throwable.class) public static State enterJobSubmit( - @Advice.This Executor executor, @Advice.Argument(value = 0, readOnly = false) Runnable task) { Runnable newTask = RunnableWrapper.wrapIfNeeded(task); - // It is important to check potentially wrapped task if we can instrument task in this - // executor. Some executors do not support wrapped tasks. - if (ExecutorInstrumentationUtils.shouldAttachStateToTask(newTask, executor)) { + if (ExecutorInstrumentationUtils.shouldAttachStateToTask(newTask)) { task = newTask; ContextStore contextStore = InstrumentationContext.get(Runnable.class, State.class); @@ -110,9 +106,7 @@ public final class JavaExecutorInstrumentation extends AbstractExecutorInstrumen @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) public static void exitJobSubmit( - @Advice.This Executor executor, - @Advice.Enter State state, - @Advice.Thrown Throwable throwable) { + @Advice.Enter State state, @Advice.Thrown Throwable throwable) { ExecutorInstrumentationUtils.cleanUpOnMethodExit(state, throwable); } } @@ -121,9 +115,8 @@ public final class JavaExecutorInstrumentation extends AbstractExecutorInstrumen @Advice.OnMethodEnter(suppress = Throwable.class) public static State enterJobSubmit( - @Advice.This Executor executor, @Advice.Argument(value = 0, readOnly = false) ForkJoinTask task) { - if (ExecutorInstrumentationUtils.shouldAttachStateToTask(task, executor)) { + if (ExecutorInstrumentationUtils.shouldAttachStateToTask(task)) { ContextStore contextStore = InstrumentationContext.get(ForkJoinTask.class, State.class); return ExecutorInstrumentationUtils.setupState(contextStore, task, Context.current()); @@ -133,9 +126,7 @@ public final class JavaExecutorInstrumentation extends AbstractExecutorInstrumen @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) public static void exitJobSubmit( - @Advice.This Executor executor, - @Advice.Enter State state, - @Advice.Thrown Throwable throwable) { + @Advice.Enter State state, @Advice.Thrown Throwable throwable) { ExecutorInstrumentationUtils.cleanUpOnMethodExit(state, throwable); } } @@ -144,12 +135,9 @@ public final class JavaExecutorInstrumentation extends AbstractExecutorInstrumen @Advice.OnMethodEnter(suppress = Throwable.class) public static State enterJobSubmit( - @Advice.This Executor executor, @Advice.Argument(value = 0, readOnly = false) Runnable task) { Runnable newTask = RunnableWrapper.wrapIfNeeded(task); - // It is important to check potentially wrapped task if we can instrument task in this - // executor. Some executors do not support wrapped tasks. - if (ExecutorInstrumentationUtils.shouldAttachStateToTask(newTask, executor)) { + if (ExecutorInstrumentationUtils.shouldAttachStateToTask(newTask)) { task = newTask; ContextStore contextStore = InstrumentationContext.get(Runnable.class, State.class); @@ -160,7 +148,6 @@ public final class JavaExecutorInstrumentation extends AbstractExecutorInstrumen @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) public static void exitJobSubmit( - @Advice.This Executor executor, @Advice.Enter State state, @Advice.Thrown Throwable throwable, @Advice.Return Future future) { @@ -177,12 +164,9 @@ public final class JavaExecutorInstrumentation extends AbstractExecutorInstrumen @Advice.OnMethodEnter(suppress = Throwable.class) public static State enterJobSubmit( - @Advice.This Executor executor, @Advice.Argument(value = 0, readOnly = false) Callable task) { Callable newTask = CallableWrapper.wrapIfNeeded(task); - // It is important to check potentially wrapped task if we can instrument task in this - // executor. Some executors do not support wrapped tasks. - if (ExecutorInstrumentationUtils.shouldAttachStateToTask(newTask, executor)) { + if (ExecutorInstrumentationUtils.shouldAttachStateToTask(newTask)) { task = newTask; ContextStore contextStore = InstrumentationContext.get(Callable.class, State.class); @@ -193,7 +177,6 @@ public final class JavaExecutorInstrumentation extends AbstractExecutorInstrumen @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) public static void exitJobSubmit( - @Advice.This Executor executor, @Advice.Enter State state, @Advice.Thrown Throwable throwable, @Advice.Return Future future) { @@ -210,7 +193,6 @@ public final class JavaExecutorInstrumentation extends AbstractExecutorInstrumen @Advice.OnMethodEnter(suppress = Throwable.class) public static Collection submitEnter( - @Advice.This Executor executor, @Advice.Argument(value = 0, readOnly = false) Collection> tasks) { if (tasks != null) { Collection> wrappedTasks = new ArrayList<>(tasks.size()); @@ -231,7 +213,6 @@ public final class JavaExecutorInstrumentation extends AbstractExecutorInstrumen @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) public static void submitExit( - @Advice.This Executor executor, @Advice.Enter Collection> wrappedTasks, @Advice.Thrown Throwable throwable) { /* diff --git a/instrumentation/java-concurrent/src/main/java/io/opentelemetry/instrumentation/auto/javaconcurrent/ScalaExecutorInstrumentation.java b/instrumentation/java-concurrent/src/main/java/io/opentelemetry/instrumentation/auto/javaconcurrent/ScalaExecutorInstrumentation.java index 087c34f148..79b44da805 100644 --- a/instrumentation/java-concurrent/src/main/java/io/opentelemetry/instrumentation/auto/javaconcurrent/ScalaExecutorInstrumentation.java +++ b/instrumentation/java-concurrent/src/main/java/io/opentelemetry/instrumentation/auto/javaconcurrent/ScalaExecutorInstrumentation.java @@ -30,7 +30,6 @@ import io.opentelemetry.instrumentation.auto.api.concurrent.State; import io.opentelemetry.javaagent.tooling.Instrumenter; import java.util.HashMap; import java.util.Map; -import java.util.concurrent.Executor; import net.bytebuddy.asm.Advice; import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.matcher.ElementMatcher; @@ -70,9 +69,8 @@ public final class ScalaExecutorInstrumentation extends AbstractExecutorInstrume @Advice.OnMethodEnter(suppress = Throwable.class) public static State enterJobSubmit( - @Advice.This Executor executor, @Advice.Argument(value = 0, readOnly = false) ForkJoinTask task) { - if (ExecutorInstrumentationUtils.shouldAttachStateToTask(task, executor)) { + if (ExecutorInstrumentationUtils.shouldAttachStateToTask(task)) { ContextStore contextStore = InstrumentationContext.get(ForkJoinTask.class, State.class); return ExecutorInstrumentationUtils.setupState(contextStore, task, Context.current()); @@ -82,9 +80,7 @@ public final class ScalaExecutorInstrumentation extends AbstractExecutorInstrume @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) public static void exitJobSubmit( - @Advice.This Executor executor, - @Advice.Enter State state, - @Advice.Thrown Throwable throwable) { + @Advice.Enter State state, @Advice.Thrown Throwable throwable) { ExecutorInstrumentationUtils.cleanUpOnMethodExit(state, throwable); } }