Skip to content

Commit 23d97f1

Browse files
committed
use class of the executor
1 parent 5191434 commit 23d97f1

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

instrumentation/executors/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/executors/JavaExecutorInstrumentation.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.Collection;
2828
import java.util.Collections;
2929
import java.util.concurrent.Callable;
30-
import java.util.concurrent.Executor;
3130
import java.util.concurrent.ForkJoinTask;
3231
import java.util.concurrent.Future;
3332
import net.bytebuddy.asm.Advice;
@@ -91,9 +90,10 @@ public static class SetExecuteRunnableStateAdvice {
9190

9291
@Advice.OnMethodEnter(suppress = Throwable.class)
9392
public static PropagatedContext enterJobSubmit(
93+
@Advice.This Object executor,
9494
@Advice.Argument(value = 0, readOnly = false) Runnable task,
9595
@Advice.Local("otelCallDepth") CallDepth callDepth) {
96-
callDepth = CallDepth.forClass(Executor.class);
96+
callDepth = CallDepth.forClass(executor.getClass());
9797
if (callDepth.getAndIncrement() > 0) {
9898
return null;
9999
}
@@ -155,9 +155,10 @@ public static class SetSubmitRunnableStateAdvice {
155155

156156
@Advice.OnMethodEnter(suppress = Throwable.class)
157157
public static PropagatedContext enterJobSubmit(
158+
@Advice.This Object executor,
158159
@Advice.Argument(value = 0, readOnly = false) Runnable task,
159160
@Advice.Local("otelCallDepth") CallDepth callDepth) {
160-
callDepth = CallDepth.forClass(Executor.class);
161+
callDepth = CallDepth.forClass(executor.getClass());
161162
if (callDepth.getAndIncrement() > 0) {
162163
return null;
163164
}
@@ -196,8 +197,10 @@ public static class SetCallableStateAdvice {
196197

197198
@Advice.OnMethodEnter(suppress = Throwable.class)
198199
public static PropagatedContext enterJobSubmit(
199-
@Advice.Argument(0) Callable<?> task, @Advice.Local("otelCallDepth") CallDepth callDepth) {
200-
callDepth = CallDepth.forClass(Executor.class);
200+
@Advice.This Object executor,
201+
@Advice.Argument(0) Callable<?> task,
202+
@Advice.Local("otelCallDepth") CallDepth callDepth) {
203+
callDepth = CallDepth.forClass(executor.getClass());
201204
if (callDepth.getAndIncrement() > 0) {
202205
return null;
203206
}
@@ -236,13 +239,14 @@ public static class SetCallableStateForCallableCollectionAdvice {
236239

237240
@Advice.OnMethodEnter(suppress = Throwable.class)
238241
public static Collection<?> submitEnter(
242+
@Advice.This Object executor,
239243
@Advice.Argument(0) Collection<? extends Callable<?>> tasks,
240244
@Advice.Local("otelCallDepth") CallDepth callDepth) {
241245
if (tasks == null) {
242246
return Collections.emptyList();
243247
}
244248

245-
callDepth = CallDepth.forClass(Executor.class);
249+
callDepth = CallDepth.forClass(executor.getClass());
246250
if (callDepth.getAndIncrement() > 0) {
247251
return Collections.emptyList();
248252
}

0 commit comments

Comments
 (0)