Repository: open-telemetry/opentelemetry-python

Issue:
Update Zipkin status code and error tag
From the [specs](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk_exporters/zipkin.md#status), Zipkin exporter exported tag for status code should be string representation.

Also, needs an `error` tag for if status is error.


Discussion:
Assign this to me.

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
@@ -82,6 +82,7 @@
 from opentelemetry.exporter.zipkin.gen import zipkin_pb2
 from opentelemetry.sdk.trace.export import SpanExporter, SpanExportResult
 from opentelemetry.trace import Span, SpanContext, SpanKind
+from opentelemetry.trace.status import StatusCode
 
 TRANSPORT_FORMAT_JSON = "json"
 TRANSPORT_FORMAT_PROTOBUF = "protobuf"
@@ -237,14 +238,14 @@ def _translate_to_json(self, spans: Sequence[Span]):
                     "otel.instrumentation_library.version"
                 ] = span.instrumentation_info.version
 
-            if span.status is not None:
-                zipkin_span["tags"]["otel.status_code"] = str(
-                    span.status.status_code.value
-                )
-                if span.status.description is not None:
-                    zipkin_span["tags"][
-                        "otel.status_description"
-                    ] = span.status.description
+            if span.status.status_code is not StatusCode.UNSET:
+                zipkin_span["tags"][
+                    "otel.status_code"
+                ] = span.status.status_code.name
+                if span.status.status_code is StatusCode.ERROR:
+                    zipkin_span["tags"]["error"] = (
+                        span.status.description or ""
+                    )
 
             if context.trace_flags.sampled:
                 zipkin_span["debug"] = True
@@ -317,13 +318,13 @@ def _translate_to_protobuf(self, spans: Sequence[Span]):
                     }
                 )
 
-            if span.status is not None:
+            if span.status.status_code is not StatusCode.UNSET:
                 pbuf_span.tags.update(
-                    {"otel.status_code": str(span.status.status_code.value)}
+                    {"otel.status_code": span.status.status_code.name}
                 )
-                if span.status.description is not None:
+                if span.status.status_code is StatusCode.ERROR:
                     pbuf_span.tags.update(
-                        {"otel.status_description": span.status.description}
+                        {"error": span.status.description or ""}
                     )
 
             if context.trace_flags.sampled:


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
@@ -246,8 +246,8 @@ def test_export_json(self):
                     "key_bool": "False",
                     "key_string": "hello_world",
                     "key_float": "111.22",
-                    "otel.status_code": "2",
-                    "otel.status_description": "Example description",
+                    "otel.status_code": "ERROR",
+                    "error": "Example description",
                 },
                 "debug": True,
                 "parentId": format(parent_id, "x"),
@@ -272,10 +272,7 @@ def test_export_json(self):
                 "duration": durations[1] // 10 ** 3,
                 "localEndpoint": local_endpoint,
                 "kind": span_kind,
-                "tags": {
-                    "key_resource": "some_resource",
-                    "otel.status_code": "1",
-                },
+                "tags": {"key_resource": "some_resource"},
                 "annotations": None,
             },
             {
@@ -289,7 +286,6 @@ def test_export_json(self):
                 "tags": {
                     "key_string": "hello_world",
                     "key_resource": "some_resource",
-                    "otel.status_code": "1",
                 },
                 "annotations": None,
             },
@@ -304,7 +300,6 @@ def test_export_json(self):
                 "tags": {
                     "otel.instrumentation_library.name": "name",
                     "otel.instrumentation_library.version": "version",
-                    "otel.status_code": "1",
                 },
                 "annotations": None,
             },
@@ -383,7 +378,7 @@ def test_export_json_zero_padding(self):
                 "duration": duration // 10 ** 3,
                 "localEndpoint": local_endpoint,
                 "kind": SPAN_KIND_MAP_JSON[SpanKind.INTERNAL],
-                "tags": {"otel.status_code": "1"},
+                "tags": {},
                 "annotations": None,
                 "debug": True,
                 "parentId": "0aaaaaaaaaaaaaaa",
@@ -737,6 +732,7 @@ def test_export_protobuf(self):
         otel_spans[1].resource = Resource(
             attributes={"key_resource": "some_resource"}
         )
+        otel_spans[1].set_status(Status(StatusCode.OK))
         otel_spans[1].end(end_time=end_times[1])
 
         otel_spans[2].start(start_time=start_times[2])
@@ -775,8 +771,8 @@ def test_export_protobuf(self):
                         "key_bool": "False",
                         "key_string": "hello_world",
                         "key_float": "111.22",
-                        "otel.status_code": "2",
-                        "otel.status_description": "Example description",
+                        "otel.status_code": "ERROR",
+                        "error": "Example description",
                     },
                     debug=True,
                     parent_id=ZipkinSpanExporter.format_pbuf_span_id(
@@ -809,7 +805,7 @@ def test_export_protobuf(self):
                     kind=span_kind,
                     tags={
                         "key_resource": "some_resource",
-                        "otel.status_code": "1",
+                        "otel.status_code": "OK",
                     },
                 ),
                 zipkin_pb2.Span(
@@ -825,7 +821,6 @@ def test_export_protobuf(self):
                     tags={
                         "key_string": "hello_world",
                         "key_resource": "some_resource",
-                        "otel.status_code": "1",
                     },
                 ),
                 zipkin_pb2.Span(
@@ -841,7 +836,6 @@ def test_export_protobuf(self):
                     tags={
                         "otel.instrumentation_library.name": "name",
                         "otel.instrumentation_library.version": "version",
-                        "otel.status_code": "1",
                     },
                 ),
             ],