Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit f544c4a

Browse files
tcolgateBogdan Drutu
authored andcommitted
fix: jaeger trace_id conversion only uses 64 bits (#236)
1 parent 9cd14d3 commit f544c4a

2 files changed

Lines changed: 17 additions & 15 deletions

File tree

opencensus/trace/exporters/jaeger_exporter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ def translate_to_jaeger(self, span_datas):
216216
parent_span_id = span.parent_span_id
217217

218218
jaeger_span = jaeger.Span(
219-
traceIdHigh=_convert_hex_str_to_int(trace_id[0:8]),
220-
traceIdLow=_convert_hex_str_to_int(trace_id[8:16]),
219+
traceIdHigh=_convert_hex_str_to_int(trace_id[0:16]),
220+
traceIdLow=_convert_hex_str_to_int(trace_id[16:32]),
221221
spanId=_convert_hex_str_to_int(span_id),
222222
operationName=span.name,
223223
startTime=int(round(start_microsec)),
@@ -242,8 +242,8 @@ def _extract_refs_from_span(span):
242242
trace_id = link.trace_id
243243
refs.append(jaeger.SpanRef(
244244
refType=_convert_reftype_to_jaeger_reftype(link.type),
245-
traceIdHigh=_convert_hex_str_to_int(trace_id[0:8]),
246-
traceIdLow=_convert_hex_str_to_int(trace_id[8:16]),
245+
traceIdHigh=_convert_hex_str_to_int(trace_id[0:16]),
246+
traceIdLow=_convert_hex_str_to_int(trace_id[16:32]),
247247
spanId=_convert_hex_str_to_int(link.span_id)))
248248
return refs
249249

tests/unit/trace/exporters/test_jaeger_exporter.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ def test_emit_succeeded(self, translate_mock, collector_mock, agent_mock):
172172

173173
def test_translate_to_jaeger(self):
174174
self.maxDiff = None
175-
trace_id = '6e0c63257de34c92bf9efcd03927272e'
175+
trace_id_high = '6e0c63257de34c92'
176+
trace_id_low = 'bf9efcd03927272e'
177+
trace_id= trace_id_high + trace_id_low
176178
span_id = '6e0c63257de34c92'
177179
parent_span_id = '1111111111111111'
178180

@@ -264,8 +266,8 @@ def test_translate_to_jaeger(self):
264266
spans = exporter.translate_to_jaeger(span_datas)
265267
expected_spans = [
266268
jaeger.Span(
267-
traceIdHigh=1846305573,
268-
traceIdLow=2112048274,
269+
traceIdHigh=7929822056569588882,
270+
traceIdLow=-4638992594902767826,
269271
spanId=7929822056569588882,
270272
parentSpanId=1229782938247303441,
271273
operationName='test1',
@@ -294,18 +296,18 @@ def test_translate_to_jaeger(self):
294296
references=[
295297
jaeger.SpanRef(
296298
refType=jaeger.SpanRefType.CHILD_OF,
297-
traceIdHigh=1846305573,
298-
traceIdLow=2112048274,
299+
traceIdHigh=7929822056569588882,
300+
traceIdLow=-4638992594902767826,
299301
spanId=7929822056569588882),
300302
jaeger.SpanRef(
301303
refType=jaeger.SpanRefType.FOLLOWS_FROM,
302-
traceIdHigh=1846305573,
303-
traceIdLow=2112048274,
304+
traceIdHigh=7929822056569588882,
305+
traceIdLow=-4638992594902767826,
304306
spanId=7929822056569588882),
305307
jaeger.SpanRef(
306308
refType=None,
307-
traceIdHigh=1846305573,
308-
traceIdLow=2112048274,
309+
traceIdHigh=7929822056569588882,
310+
traceIdLow=-4638992594902767826,
309311
spanId=7929822056569588882)
310312
],
311313
logs=[
@@ -328,8 +330,8 @@ def test_translate_to_jaeger(self):
328330
]),
329331
jaeger.Span(
330332
operationName="test2",
331-
traceIdHigh=1846305573,
332-
traceIdLow=2112048274,
333+
traceIdHigh=7929822056569588882,
334+
traceIdLow=-4638992594902767826,
333335
spanId=7929822056569588882,
334336
parentSpanId=0,
335337
startTime=1502820146071158,

0 commit comments

Comments
 (0)