Skip to content

Commit 583279c

Browse files
committed
Fix Jaeger status
Based on the changes of open-telemetry#358 Signed-off-by: Daniel González Lopes <[email protected]>
1 parent 5232a8b commit 583279c

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

ext/opentelemetry-ext-jaeger/src/opentelemetry/ext/jaeger/__init__.py

+12-13
Original file line numberDiff line numberDiff line change
@@ -156,20 +156,19 @@ def _translate_to_jaeger(spans: Span):
156156

157157
tags = _extract_tags(span.attributes)
158158

159-
if status is not None:
160-
if tags is None:
161-
tags = []
162-
163-
tags.extend(
164-
[
165-
_get_long_tag("status.code", status.canonical_code.value),
166-
_get_string_tag("status.message", status.description),
167-
]
168-
)
159+
if tags is None:
160+
tags = []
161+
162+
tags.extend(
163+
[
164+
_get_long_tag("status.code", status.canonical_code.value),
165+
_get_string_tag("status.message", status.description),
166+
]
167+
)
169168

170-
# Ensure that if Status.Code is not OK, that we set the "error" tag on the Jaeger span.
171-
if status.canonical_code is not StatusCanonicalCode.OK:
172-
tags.append(_get_bool_tag("error", True))
169+
# Ensure that if Status.Code is not OK, that we set the "error" tag on the Jaeger span.
170+
if status.canonical_code is not StatusCanonicalCode.OK:
171+
tags.append(_get_bool_tag("error", True))
173172

174173
refs = _extract_refs_from_span(span)
175174
logs = _extract_logs_from_span(span)

ext/opentelemetry-ext-jaeger/tests/test_jaeger_exporter.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ def test_translate_to_jaeger(self):
156156
context=other_context, attributes=link_attributes
157157
)
158158

159+
default_status_tags = [
160+
jaeger.Tag(key="status.code", vType=jaeger.TagType.LONG, vLong=0,),
161+
jaeger.Tag(
162+
key="status.message", vType=jaeger.TagType.STRING, vStr=None,
163+
),
164+
]
165+
159166
otel_spans = [
160167
trace.Span(
161168
name=span_names[0],
@@ -176,7 +183,7 @@ def test_translate_to_jaeger(self):
176183
otel_spans[0].set_attribute("key_string", "hello_world")
177184
otel_spans[0].set_attribute("key_float", 111.22)
178185
otel_spans[0].set_status(
179-
Status(StatusCanonicalCode.OK, "Example description")
186+
Status(StatusCanonicalCode.UNKNOWN, "Example description")
180187
)
181188
otel_spans[0].end(end_time=end_times[0])
182189

@@ -214,13 +221,16 @@ def test_translate_to_jaeger(self):
214221
vDouble=111.22,
215222
),
216223
jaeger.Tag(
217-
key="status.code", vType=jaeger.TagType.LONG, vLong=0,
224+
key="status.code", vType=jaeger.TagType.LONG, vLong=2,
218225
),
219226
jaeger.Tag(
220227
key="status.message",
221228
vType=jaeger.TagType.STRING,
222229
vStr="Example description",
223230
),
231+
jaeger.Tag(
232+
key="error", vType=jaeger.TagType.BOOL, vBool=True,
233+
),
224234
],
225235
references=[
226236
jaeger.SpanRef(
@@ -267,6 +277,7 @@ def test_translate_to_jaeger(self):
267277
startTime=start_times[1] // 10 ** 3,
268278
duration=durations[1] // 10 ** 3,
269279
flags=0,
280+
tags=default_status_tags,
270281
),
271282
jaeger.Span(
272283
operationName=span_names[2],
@@ -277,6 +288,7 @@ def test_translate_to_jaeger(self):
277288
startTime=start_times[2] // 10 ** 3,
278289
duration=durations[2] // 10 ** 3,
279290
flags=0,
291+
tags=default_status_tags,
280292
),
281293
]
282294

0 commit comments

Comments
 (0)