-
Notifications
You must be signed in to change notification settings - Fork 331
Expand file tree
/
Copy pathTraceCorrelationTest.groovy
More file actions
44 lines (37 loc) · 1.64 KB
/
TraceCorrelationTest.groovy
File metadata and controls
44 lines (37 loc) · 1.64 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
36
37
38
39
40
41
42
43
44
import datadog.trace.agent.test.InstrumentationSpecification
import datadog.trace.config.inversion.ConfigHelper
import datadog.trace.api.CorrelationIdentifier
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
class TraceCorrelationTest extends InstrumentationSpecification {
@Override
protected void configurePreAgent() {
super.configurePreAgent()
// Opt out of strict config validation - test module loads test instrumentations with fake names
ConfigHelper.get().setConfigInversionStrict(ConfigHelper.StrictnessPolicy.TEST)
}
def "access trace correlation only under trace"() {
when:
def span = TEST_TRACER.startSpan("test", "myspan")
def scope = TEST_TRACER.activateManualSpan(span)
then:
CorrelationIdentifier.traceId == (span.traceId.toHighOrderLong() == 0 ? span.traceId.toString() : span.traceId.toHexString())
CorrelationIdentifier.spanId == span.spanId.toString()
when:
scope.close()
span.finish()
then:
CorrelationIdentifier.traceId == "0"
CorrelationIdentifier.spanId == "0"
}
}
class Trace128bitCorrelationTest extends TraceCorrelationTest {
@Override
void configurePreAgent() {
super.configurePreAgent()
// Opt out of strict config validation - test module loads test instrumentations with fake names
ConfigHelper.get().setConfigInversionStrict(ConfigHelper.StrictnessPolicy.TEST)
injectSysConfig(TRACE_128_BIT_TRACEID_GENERATION_ENABLED, "true")
injectSysConfig(TRACE_128_BIT_TRACEID_LOGGING_ENABLED, "true")
}
}