Repository: open-telemetry/opentelemetry-python

Issue:
Zipkin exporter must map status
As per spec: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk_exporters/zipkin.md#status


Discussion:
Hi @codeboten, just joined @alolita team on AWS. Can I take this on as my first issue?
Sounds great! 

Resolving patch:
diff --git a/exporter/opentelemetry-exporter-zipkin/src/opentelemetry/exporter/zipkin/__init__.py b/exporter/opentelemetry-exporter-zipkin/src/opentelemetry/exporter/zipkin/__init__.py
--- a/exporter/opentelemetry-exporter-zipkin/src/opentelemetry/exporter/zipkin/__init__.py
+++ b/exporter/opentelemetry-exporter-zipkin/src/opentelemetry/exporter/zipkin/__init__.py
@@ -183,6 +183,15 @@ def _translate_to_zipkin(self, spans: Sequence[Span]):
                     "otel.instrumentation_library.version"
                 ] = span.instrumentation_info.version
 
+            if span.status is not None:
+                zipkin_span["tags"][
+                    "otel.status_code"
+                ] = span.status.canonical_code.value
+                if span.status.description is not None:
+                    zipkin_span["tags"][
+                        "otel.status_description"
+                    ] = span.status.description
+
             if context.trace_flags.sampled:
                 zipkin_span["debug"] = True
 


Test patch:
diff --git a/exporter/opentelemetry-exporter-zipkin/tests/test_zipkin_exporter.py b/exporter/opentelemetry-exporter-zipkin/tests/test_zipkin_exporter.py
--- a/exporter/opentelemetry-exporter-zipkin/tests/test_zipkin_exporter.py
+++ b/exporter/opentelemetry-exporter-zipkin/tests/test_zipkin_exporter.py
@@ -24,6 +24,7 @@
 from opentelemetry.sdk.trace.export import SpanExportResult
 from opentelemetry.sdk.util.instrumentation import InstrumentationInfo
 from opentelemetry.trace import TraceFlags
+from opentelemetry.trace.status import Status, StatusCanonicalCode
 
 
 class MockResponse:
@@ -174,6 +175,9 @@ def test_export(self):
         otel_spans[0].set_attribute("key_bool", False)
         otel_spans[0].set_attribute("key_string", "hello_world")
         otel_spans[0].set_attribute("key_float", 111.22)
+        otel_spans[0].set_status(
+            Status(StatusCanonicalCode.UNKNOWN, "Example description")
+        )
         otel_spans[0].end(end_time=end_times[0])
 
         otel_spans[1].start(start_time=start_times[1])
@@ -213,6 +217,8 @@ def test_export(self):
                     "key_bool": "False",
                     "key_string": "hello_world",
                     "key_float": "111.22",
+                    "otel.status_code": 2,
+                    "otel.status_description": "Example description",
                 },
                 "annotations": [
                     {
@@ -231,7 +237,10 @@ def test_export(self):
                 "duration": durations[1] // 10 ** 3,
                 "localEndpoint": local_endpoint,
                 "kind": None,
-                "tags": {"key_resource": "some_resource"},
+                "tags": {
+                    "key_resource": "some_resource",
+                    "otel.status_code": 0,
+                },
                 "annotations": None,
             },
             {
@@ -245,6 +254,7 @@ def test_export(self):
                 "tags": {
                     "key_string": "hello_world",
                     "key_resource": "some_resource",
+                    "otel.status_code": 0,
                 },
                 "annotations": None,
             },
@@ -259,6 +269,7 @@ def test_export(self):
                 "tags": {
                     "otel.instrumentation_library.name": "name",
                     "otel.instrumentation_library.version": "version",
+                    "otel.status_code": 0,
                 },
                 "annotations": None,
             },
@@ -324,7 +335,7 @@ def test_zero_padding(self):
                 "duration": duration // 10 ** 3,
                 "localEndpoint": local_endpoint,
                 "kind": None,
-                "tags": {},
+                "tags": {"otel.status_code": 0},
                 "annotations": None,
                 "debug": True,
                 "parentId": "0aaaaaaaaaaaaaaa",