-
Notifications
You must be signed in to change notification settings - Fork 333
Expand file tree
/
Copy pathTraceCorrelationTest.groovy
More file actions
35 lines (28 loc) · 1.12 KB
/
TraceCorrelationTest.groovy
File metadata and controls
35 lines (28 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import datadog.trace.agent.test.InstrumentationSpecification
import static datadog.trace.api.config.TraceInstrumentationConfig.TRACE_128_BIT_TRACEID_LOGGING_ENABLED
import static datadog.trace.api.config.TracerConfig.TRACE_128_BIT_TRACEID_GENERATION_ENABLED
import datadog.trace.api.GlobalTracer
class TraceCorrelationTest extends InstrumentationSpecification {
def "access trace correlation only under trace"() {
when:
def span = TEST_TRACER.startSpan("test", "myspan")
def scope = TEST_TRACER.activateManualSpan(span)
then:
GlobalTracer.get().traceId == (span.traceId.toHighOrderLong() == 0 ? span.traceId.toString() : span.traceId.toHexString())
GlobalTracer.get().spanId == span.spanId.toString()
when:
scope.close()
span.finish()
then:
GlobalTracer.get().traceId == "0"
GlobalTracer.get().spanId == "0"
}
}
class Trace128bitCorrelationTest extends TraceCorrelationTest {
@Override
void configurePreAgent() {
super.configurePreAgent()
injectSysConfig(TRACE_128_BIT_TRACEID_GENERATION_ENABLED, "true")
injectSysConfig(TRACE_128_BIT_TRACEID_LOGGING_ENABLED, "true")
}
}