Skip to content

Commit b8a8016

Browse files
authored
exporter/zipkin: Fix zipkin exporter translation bug (#1149)
Zipkin exporter translation was setting `otel.status_code` attribute as an integer which resulted in Otel collector rejecting the spans. This commit casts the value to a string.
1 parent 30f79fd commit b8a8016

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

exporter/opentelemetry-exporter-zipkin/src/opentelemetry/exporter/zipkin/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ def _translate_to_zipkin(self, spans: Sequence[Span]):
184184
] = span.instrumentation_info.version
185185

186186
if span.status is not None:
187-
zipkin_span["tags"][
188-
"otel.status_code"
189-
] = span.status.canonical_code.value
187+
zipkin_span["tags"]["otel.status_code"] = str(
188+
span.status.canonical_code.value
189+
)
190190
if span.status.description is not None:
191191
zipkin_span["tags"][
192192
"otel.status_description"

exporter/opentelemetry-exporter-zipkin/tests/test_zipkin_exporter.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def test_export(self):
217217
"key_bool": "False",
218218
"key_string": "hello_world",
219219
"key_float": "111.22",
220-
"otel.status_code": 2,
220+
"otel.status_code": "2",
221221
"otel.status_description": "Example description",
222222
},
223223
"annotations": [
@@ -239,7 +239,7 @@ def test_export(self):
239239
"kind": None,
240240
"tags": {
241241
"key_resource": "some_resource",
242-
"otel.status_code": 0,
242+
"otel.status_code": "0",
243243
},
244244
"annotations": None,
245245
},
@@ -254,7 +254,7 @@ def test_export(self):
254254
"tags": {
255255
"key_string": "hello_world",
256256
"key_resource": "some_resource",
257-
"otel.status_code": 0,
257+
"otel.status_code": "0",
258258
},
259259
"annotations": None,
260260
},
@@ -269,7 +269,7 @@ def test_export(self):
269269
"tags": {
270270
"otel.instrumentation_library.name": "name",
271271
"otel.instrumentation_library.version": "version",
272-
"otel.status_code": 0,
272+
"otel.status_code": "0",
273273
},
274274
"annotations": None,
275275
},
@@ -335,7 +335,7 @@ def test_zero_padding(self):
335335
"duration": duration // 10 ** 3,
336336
"localEndpoint": local_endpoint,
337337
"kind": None,
338-
"tags": {"otel.status_code": 0},
338+
"tags": {"otel.status_code": "0"},
339339
"annotations": None,
340340
"debug": True,
341341
"parentId": "0aaaaaaaaaaaaaaa",

0 commit comments

Comments
 (0)