Skip to content

Commit e8d5938

Browse files
committed
Exclude OrderedThreadPoolExecutor from queue-time measurements
1 parent f6c50ad commit e8d5938

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/executor/ThreadPoolExecutorInstrumentation.java

+27-17
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.extendsClass;
44
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
55
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.namedOneOf;
6+
import static datadog.trace.bootstrap.instrumentation.java.concurrent.ExcludeFilter.ExcludeType.EXECUTOR;
67
import static datadog.trace.bootstrap.instrumentation.java.concurrent.ExcludeFilter.ExcludeType.RUNNABLE;
78
import static datadog.trace.bootstrap.instrumentation.java.concurrent.ExcludeFilter.ExcludeType.RUNNABLE_FUTURE;
89
import static datadog.trace.bootstrap.instrumentation.java.concurrent.ExcludeFilter.exclude;
@@ -30,6 +31,7 @@
3031
import java.util.Collection;
3132
import java.util.Collections;
3233
import java.util.HashMap;
34+
import java.util.List;
3335
import java.util.Map;
3436
import java.util.Queue;
3537
import java.util.concurrent.RunnableFuture;
@@ -129,11 +131,17 @@ public void methodAdvice(MethodTransformer transformer) {
129131

130132
@Override
131133
public Map<ExcludeFilter.ExcludeType, ? extends Collection<String>> excludedClasses() {
132-
return Collections.singletonMap(
134+
Map<ExcludeFilter.ExcludeType, List<String>> map = new HashMap<>(2);
135+
map.put(
133136
RUNNABLE,
134137
Arrays.asList(
135138
"datadog.trace.bootstrap.instrumentation.java.concurrent.Wrapper",
136139
"datadog.trace.bootstrap.instrumentation.java.concurrent.ComparableRunnable"));
140+
map.put(
141+
EXECUTOR,
142+
Collections.singletonList("org.apache.mina.filter.executor.OrderedThreadPoolExecutor"));
143+
144+
return Collections.unmodifiableMap(map);
137145
}
138146

139147
public static final class Init {
@@ -162,22 +170,24 @@ public static void capture(
162170
// queue time needs to be handled separately because there are RunnableFutures which are
163171
// excluded as
164172
// Runnables but it is not until now that they will be put on the executor's queue
165-
if (!exclude(RUNNABLE, task)) {
166-
Queue<?> queue = tpe.getQueue();
167-
QueueTimerHelper.startQueuingTimer(
168-
InstrumentationContext.get(Runnable.class, State.class),
169-
tpe.getClass(),
170-
queue.getClass(),
171-
queue.size(),
172-
task);
173-
} else if (!exclude(RUNNABLE_FUTURE, task) && task instanceof RunnableFuture) {
174-
Queue<?> queue = tpe.getQueue();
175-
QueueTimerHelper.startQueuingTimer(
176-
InstrumentationContext.get(RunnableFuture.class, State.class),
177-
tpe.getClass(),
178-
queue.getClass(),
179-
queue.size(),
180-
(RunnableFuture<?>) task);
173+
if (!exclude(EXECUTOR, tpe)) {
174+
if (!exclude(RUNNABLE, task)) {
175+
Queue<?> queue = tpe.getQueue();
176+
QueueTimerHelper.startQueuingTimer(
177+
InstrumentationContext.get(Runnable.class, State.class),
178+
tpe.getClass(),
179+
queue.getClass(),
180+
queue.size(),
181+
task);
182+
} else if (!exclude(RUNNABLE_FUTURE, task) && task instanceof RunnableFuture) {
183+
Queue<?> queue = tpe.getQueue();
184+
QueueTimerHelper.startQueuingTimer(
185+
InstrumentationContext.get(RunnableFuture.class, State.class),
186+
tpe.getClass(),
187+
queue.getClass(),
188+
queue.size(),
189+
(RunnableFuture<?>) task);
190+
}
181191
}
182192
}
183193
}

0 commit comments

Comments
 (0)