forked from DataDog/dd-trace-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_helpers.py
38 lines (29 loc) · 1.32 KB
/
test_helpers.py
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
from ddtrace import helpers
from nose.tools import eq_, ok_
from .base import BaseTracerTestCase
from .util import override_global_tracer
class HelpersTestCase(BaseTracerTestCase):
"""Test suite for ``ddtrace`` helpers"""
def test_correlation_identifiers(self):
# ensures the right correlation identifiers are
# returned when a Trace is active
with override_global_tracer(self.tracer):
span = self.tracer.trace('MockSpan')
active_trace_id, active_span_id = span.trace_id, span.span_id
trace_id, span_id = helpers.get_correlation_ids()
eq_(trace_id, active_trace_id)
eq_(span_id, active_span_id)
def test_correlation_identifiers_without_trace(self):
# ensures `None` is returned if no Traces are active
with override_global_tracer(self.tracer):
trace_id, span_id = helpers.get_correlation_ids()
ok_(trace_id is None)
ok_(span_id is None)
def test_correlation_identifiers_with_disabled_trace(self):
# ensures `None` is returned if tracer is disabled
with override_global_tracer(self.tracer):
self.tracer.enabled = False
self.tracer.trace('MockSpan')
trace_id, span_id = helpers.get_correlation_ids()
ok_(trace_id is None)
ok_(span_id is None)