Skip to content

Commit 70da71a

Browse files
committed
Setting TextPropagator as default
Setting TextPropagator as default propagator for TEXT_MAP and HTTP_HEADERS
1 parent 51cdee1 commit 70da71a

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

examples/http/context_in_headers.py

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import opentracing
3030
import opentracing.ext.tags
3131
import lightstep
32+
from opentracing import Format
33+
from lightstep.b3_propagator import B3Propagator
3234

3335

3436
class RemoteHandler(BaseHTTPRequestHandler):
@@ -145,6 +147,12 @@ def lightstep_tracer_from_args():
145147
if __name__ == '__main__':
146148
with lightstep_tracer_from_args() as tracer:
147149
opentracing.tracer = tracer
150+
151+
opentracing.tracer.register_propagator(Format.TEXT_MAP, B3Propagator())
152+
opentracing.tracer.register_propagator(
153+
Format.HTTP_HEADERS, B3Propagator()
154+
)
155+
148156
global _exit_code
149157
_exit_code = 0
150158

lightstep/tracer.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from __future__ import absolute_import
1010

1111
from basictracer import BasicTracer
12-
from lightstep.b3_propagator import B3Propagator
12+
from basictracer.text_propagator import TextPropagator
1313
from opentracing import Format
1414

1515
from lightstep.lightstep_binary_propagator import LightStepBinaryPropagator
@@ -73,8 +73,8 @@ class _LightstepTracer(BasicTracer):
7373
def __init__(self, enable_binary_format, recorder, scope_manager):
7474
"""Initialize the LightStep Tracer, deferring to BasicTracer."""
7575
super(_LightstepTracer, self).__init__(recorder, scope_manager=scope_manager)
76-
self.register_propagator(Format.TEXT_MAP, B3Propagator())
77-
self.register_propagator(Format.HTTP_HEADERS, B3Propagator())
76+
self.register_propagator(Format.TEXT_MAP, TextPropagator())
77+
self.register_propagator(Format.HTTP_HEADERS, TextPropagator())
7878
if enable_binary_format:
7979
# We do this import lazily because protobuf versioning issues
8080
# can cause process-level failure at import time.

tests/b3_propagator_test.py

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from opentracing import Format
77
from lightstep import Tracer
8+
from lightstep.b3_propagator import B3Propagator
89

910

1011
class B3PropagatorTest(TestCase):
@@ -13,6 +14,7 @@ def setUp(self):
1314
periodic_flush_seconds=0,
1415
collector_host="localhost"
1516
)
17+
self._tracer.register_propagator(Format.HTTP_HEADERS, B3Propagator())
1618

1719
def tracer(self):
1820
return self._tracer

0 commit comments

Comments
 (0)