File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
dd-java-agent/instrumentation/java-concurrent/src/test/groovy/executor Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ package executor
2+
3+ import datadog.trace.agent.test.AgentTestRunner
4+ import datadog.trace.bootstrap.instrumentation.api.AgentTracer
5+
6+ import java.util.concurrent.Executors
7+ import java.util.concurrent.ThreadPoolExecutor
8+ import java.util.concurrent.atomic.AtomicBoolean
9+
10+ import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace
11+
12+ class ContextLeakTest extends AgentTestRunner {
13+
14+ def " trace should not leak into TPE Worker task when '#name'" () {
15+ setup :
16+ AtomicBoolean parentSpanActive = new AtomicBoolean (false )
17+ def tpe = Executors . newFixedThreadPool(1 ) as ThreadPoolExecutor
18+
19+ when : " tpe prestarted under an active trace"
20+ runUnderTrace(" span" ) {
21+ interaction(tpe)
22+ }
23+ // submit a probe to check if the span is active or not
24+ tpe. submit {
25+ parentSpanActive. set(AgentTracer . activeSpan()?. operationName == " span" )
26+ }. get()
27+
28+ then : " the prestart time span did not leak into the worker"
29+ ! parentSpanActive. get()
30+
31+ where :
32+ name | interaction
33+ " prestart all core threads" | { e -> assert e. prestartAllCoreThreads() > 0 : " threads already started" }
34+ " prestart core thread" | { e -> assert e. prestartCoreThread() : " thread already started" }
35+ " lazy init worker" | { e -> e. execute {} }
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments