Remove unused code (#1128)
This commit is contained in:
parent
f4a178613a
commit
7022f10b81
|
@ -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()
|
||||
|
|
|
@ -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<ForkJoinTask, State> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Runnable, State> 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<ForkJoinTask, State> 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<Runnable, State> 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<Callable, State> 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<? extends Callable<?>> tasks) {
|
||||
if (tasks != null) {
|
||||
Collection<Callable<?>> 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<? extends Callable<?>> wrappedTasks,
|
||||
@Advice.Thrown Throwable throwable) {
|
||||
/*
|
||||
|
|
|
@ -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<ForkJoinTask, State> 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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue