Skip to content

Commit

Permalink
Cleanup OTSpanTest so it doesn't call GlobalTracer.register and leak …
Browse files Browse the repository at this point in the history
…state to other tests. (#7105)

This test didn't need to register the tracer with GlobalTracer in order to test the behaviour of OTSpan - it was also failing to close the tracer, leaking threads.

With these changes we can move DDTracerResolverTest back to being a non-forked test.
  • Loading branch information
mcculls committed Jun 3, 2024
1 parent a155857 commit bffe40c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import datadog.trace.bootstrap.instrumentation.api.ResourceNamePriorities
import datadog.trace.test.util.DDSpecification
import io.opentracing.Scope
import io.opentracing.Span
import io.opentracing.util.GlobalTracer
import spock.lang.Shared

class OTSpanTest extends DDSpecification {
@Shared
DDTracer tracer = DDTracer.builder().build()

def setup() {
GlobalTracer.register(tracer)
def cleanup() {
tracer?.close()
}

def "test resource name assignment through MutableSpan casting"() {
Expand All @@ -22,9 +21,9 @@ class OTSpanTest extends DDSpecification {
OTScopeManager.OTScope testScope = tracer.activateSpan(testSpan) as OTScopeManager.OTScope

when:
Span active = GlobalTracer.get().activeSpan()
Span child = GlobalTracer.get().buildSpan("child").asChildOf(active).start()
Scope scope = GlobalTracer.get().activateSpan(child)
Span active = tracer.activeSpan()
Span child = tracer.buildSpan("child").asChildOf(active).start()
Scope scope = tracer.activateSpan(child)

MutableSpan localRootSpan = ((MutableSpan) child).getLocalRootSpan()
localRootSpan.setResourceName("correct-resource")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import io.opentracing.contrib.tracerresolver.TracerResolver

import static datadog.trace.api.config.TracerConfig.TRACE_RESOLVER_ENABLED

class DDTracerResolverForkedTest extends DDSpecification {
class DDTracerResolverTest extends DDSpecification {

def resolver = new DDTracerResolver()

Expand Down

0 comments on commit bffe40c

Please sign in to comment.