Skip to content

Commit fb45cb5

Browse files
committed
More tests; use a single tracer
1 parent c1fc36f commit fb45cb5

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

tests/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import os
2-
import sys
3-
sys.path.append("/Users/pglombardo/Projects/instana/python-sensor")
2+
import opentracing
3+
import instana.tracer
44
os.environ["INSTANA_TEST"] = "true"
5+
6+
opentracing.global_tracer = instana.tracer.InstanaTracer()

tests/test_ot_span.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
from nose.tools import assert_equals
55

66

7-
def test_span_basics():
8-
opentracing.global_tracer = instana.tracer.InstanaTracer()
7+
def test_span_interface():
98
span = opentracing.global_tracer.start_span("blah")
109
assert hasattr(span, "finish")
1110
assert hasattr(span, "set_tag")
@@ -15,3 +14,25 @@ def test_span_basics():
1514
assert hasattr(span, "get_baggage_item")
1615
assert hasattr(span, "context")
1716
assert hasattr(span, "log")
17+
18+
19+
def test_span_ids():
20+
count = 0
21+
while count <= 1000:
22+
count += 1
23+
span = opentracing.global_tracer.start_span("test_span_ids")
24+
context = span.context
25+
assert -9223372036854775808 <= context.span_id <= 9223372036854775807
26+
assert -9223372036854775808 <= context.trace_id <= 9223372036854775807
27+
28+
29+
def test_span_fields():
30+
span = opentracing.global_tracer.start_span("mycustom")
31+
assert_equals("mycustom", span.operation_name)
32+
assert span.context
33+
34+
span.set_tag("tagone", "string")
35+
span.set_tag("tagtwo", 150)
36+
37+
assert_equals("string", span.tags['tagone'])
38+
assert_equals(150, span.tags['tagtwo'])

tests/test_ot_tracer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
def test_tracer_basics():
77
assert hasattr(instana.tracer, 'InstanaTracer')
8-
opentracing.global_tracer = instana.tracer.InstanaTracer()
98
assert hasattr(opentracing.global_tracer, "start_span")
109
assert hasattr(opentracing.global_tracer, "inject")
1110
assert hasattr(opentracing.global_tracer, "extract")

0 commit comments

Comments
 (0)