Skip to content

Commit af59201

Browse files
committed
Proper id <--> header conversion
1 parent bf58ec7 commit af59201

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

instana/propagator.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import absolute_import
2-
32
import opentracing as ot
3+
from instana import util
44

55
prefix_tracer_state = 'HTTP_X_INSTANA_'
66
field_name_trace_id = prefix_tracer_state + 'T'
@@ -9,11 +9,11 @@
99

1010

1111
class HTTPPropagator():
12-
"""A Propagator for Format.TEXT_MAP."""
12+
"""A Propagator for Format.HTTP_HEADERS. """
1313

1414
def inject(self, span_context, carrier):
15-
carrier[field_name_trace_id] = '{0:x}'.format(span_context.trace_id)
16-
carrier[field_name_span_id] = '{0:x}'.format(span_context.span_id)
15+
carrier[field_name_trace_id] = util.id_to_header(span_context.trace_id)
16+
carrier[field_name_span_id] = util.id_to_header(span_context.span_id)
1717

1818
def extract(self, carrier): # noqa
1919
count = 0
@@ -22,10 +22,10 @@ def extract(self, carrier): # noqa
2222
v = carrier[k]
2323
k = k.lower()
2424
if k == field_name_span_id:
25-
span_id = int(v, 16)
25+
span_id = util.header_to_id(v)
2626
count += 1
2727
elif k == field_name_trace_id:
28-
trace_id = int(v, 16)
28+
trace_id = util.header_to_id(v)
2929
count += 1
3030

3131
if count != field_count:

0 commit comments

Comments
 (0)