Repository: open-telemetry/opentelemetry-python

Issue:
Update Jaeger exporter status code to error tag
From the [specs](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk_exporters/jaeger.md#status) Jaeger exporter tags for status code must be the string representation of the status code enum.

Related:
https://github.com/open-telemetry/opentelemetry-python/issues/1402


Discussion:
@lzchen specs is linked to open-census probably you meant this https://github.com/open-telemetry/opentelemetry-specification/pull/1257. So with this spec change tag type should be string (`OK`, `ERROR`) instead of number in exporter?

Resolving patch:
diff --git a/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/translate/protobuf.py b/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/translate/protobuf.py
--- a/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/translate/protobuf.py
+++ b/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/translate/protobuf.py
@@ -24,7 +24,7 @@
     VERSION_KEY,
     Translator,
 )
-from opentelemetry.sdk.trace import Span
+from opentelemetry.sdk.trace import Span, StatusCode
 from opentelemetry.util import types
 
 # pylint: disable=no-member,too-many-locals,no-self-use
@@ -190,16 +190,24 @@ def _extract_tags(self, span: Span) -> Sequence[model_pb2.KeyValue]:
                 if key_value:
                     translated.append(key_value)
 
-        code = _get_long_key_value(
-            "status.code", span.status.status_code.value
-        )
-        message = _get_string_key_value(
-            "status.message", span.status.description
-        )
-        kind = _get_string_key_value(
-            "span.kind", OTLP_JAEGER_SPAN_KIND[span.kind]
+        status = span.status
+        if status.status_code is not StatusCode.UNSET:
+            translated.append(
+                _get_string_key_value(
+                    "otel.status_code", status.status_code.name
+                )
+            )
+            if status.description is not None:
+                translated.append(
+                    _get_string_key_value(
+                        "otel.status_description", status.description
+                    )
+                )
+        translated.append(
+            _get_string_key_value(
+                "span.kind", OTLP_JAEGER_SPAN_KIND[span.kind]
+            )
         )
-        translated.extend([code, message, kind])
 
         # Instrumentation info KeyValues
         if span.instrumentation_info:
diff --git a/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/translate/thrift.py b/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/translate/thrift.py
--- a/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/translate/thrift.py
+++ b/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/translate/thrift.py
@@ -23,7 +23,7 @@
     _convert_int_to_i64,
     _nsec_to_usec_round,
 )
-from opentelemetry.sdk.trace import Span
+from opentelemetry.sdk.trace import Span, StatusCode
 from opentelemetry.util import types
 
 
@@ -120,10 +120,21 @@ def _extract_tags(self, span: Span) -> Sequence[TCollector.Tag]:
                 if tag:
                     translated.append(tag)
 
-        code = _get_long_tag("status.code", span.status.status_code.value)
-        message = _get_string_tag("status.message", span.status.description)
-        kind = _get_string_tag("span.kind", OTLP_JAEGER_SPAN_KIND[span.kind])
-        translated.extend([code, message, kind])
+        status = span.status
+        if status.status_code is not StatusCode.UNSET:
+            translated.append(
+                _get_string_tag("otel.status_code", status.status_code.name)
+            )
+            if status.description is not None:
+                translated.append(
+                    _get_string_tag(
+                        "otel.status_description", status.description
+                    )
+                )
+
+        translated.append(
+            _get_string_tag("span.kind", OTLP_JAEGER_SPAN_KIND[span.kind])
+        )
 
         # Instrumentation info tags
         if span.instrumentation_info:


Test patch:
diff --git a/exporter/opentelemetry-exporter-jaeger/tests/test_jaeger_exporter_thrift.py b/exporter/opentelemetry-exporter-jaeger/tests/test_jaeger_exporter_thrift.py
--- a/exporter/opentelemetry-exporter-jaeger/tests/test_jaeger_exporter_thrift.py
+++ b/exporter/opentelemetry-exporter-jaeger/tests/test_jaeger_exporter_thrift.py
@@ -221,14 +221,6 @@ def test_translate_to_jaeger(self):
         )
 
         default_tags = [
-            jaeger.Tag(
-                key="status.code",
-                vType=jaeger.TagType.LONG,
-                vLong=StatusCode.UNSET.value,
-            ),
-            jaeger.Tag(
-                key="status.message", vType=jaeger.TagType.STRING, vStr=None
-            ),
             jaeger.Tag(
                 key="span.kind", vType=jaeger.TagType.STRING, vStr="internal",
             ),
@@ -316,12 +308,12 @@ def test_translate_to_jaeger(self):
                         vStr="some_resource",
                     ),
                     jaeger.Tag(
-                        key="status.code",
-                        vType=jaeger.TagType.LONG,
-                        vLong=StatusCode.ERROR.value,
+                        key="otel.status_code",
+                        vType=jaeger.TagType.STRING,
+                        vStr="ERROR",
                     ),
                     jaeger.Tag(
-                        key="status.message",
+                        key="otel.status_description",
                         vType=jaeger.TagType.STRING,
                         vStr="Example description",
                     ),
@@ -392,12 +384,12 @@ def test_translate_to_jaeger(self):
                 flags=0,
                 tags=[
                     jaeger.Tag(
-                        key="status.code",
-                        vType=jaeger.TagType.LONG,
-                        vLong=StatusCode.OK.value,
+                        key="otel.status_code",
+                        vType=jaeger.TagType.STRING,
+                        vStr="OK",
                     ),
                     jaeger.Tag(
-                        key="status.message",
+                        key="otel.status_description",
                         vType=jaeger.TagType.STRING,
                         vStr="Example description",
                     ),
diff --git a/exporter/opentelemetry-exporter-jaeger/tests/test_jarget_exporter_protobuf.py b/exporter/opentelemetry-exporter-jaeger/tests/test_jarget_exporter_protobuf.py
--- a/exporter/opentelemetry-exporter-jaeger/tests/test_jarget_exporter_protobuf.py
+++ b/exporter/opentelemetry-exporter-jaeger/tests/test_jarget_exporter_protobuf.py
@@ -140,16 +140,6 @@ def test_translate_to_jaeger(self):
         )
 
         default_tags = [
-            model_pb2.KeyValue(
-                key="status.code",
-                v_type=model_pb2.ValueType.INT64,
-                v_int64=StatusCode.UNSET.value,
-            ),
-            model_pb2.KeyValue(
-                key="status.message",
-                v_type=model_pb2.ValueType.STRING,
-                v_str=None,
-            ),
             model_pb2.KeyValue(
                 key="span.kind",
                 v_type=model_pb2.ValueType.STRING,
@@ -269,12 +259,12 @@ def test_translate_to_jaeger(self):
                         v_str="some_resource",
                     ),
                     model_pb2.KeyValue(
-                        key="status.code",
-                        v_type=model_pb2.ValueType.INT64,
-                        v_int64=StatusCode.ERROR.value,
+                        key="otel.status_code",
+                        v_type=model_pb2.ValueType.STRING,
+                        v_str="ERROR",
                     ),
                     model_pb2.KeyValue(
-                        key="status.message",
+                        key="otel.status_description",
                         v_type=model_pb2.ValueType.STRING,
                         v_str="Example description",
                     ),
@@ -353,12 +343,12 @@ def test_translate_to_jaeger(self):
                 flags=0,
                 tags=[
                     model_pb2.KeyValue(
-                        key="status.code",
-                        v_type=model_pb2.ValueType.INT64,
-                        v_int64=StatusCode.OK.value,
+                        key="otel.status_code",
+                        v_type=model_pb2.ValueType.STRING,
+                        v_str="OK",
                     ),
                     model_pb2.KeyValue(
-                        key="status.message",
+                        key="otel.status_description",
                         v_type=model_pb2.ValueType.STRING,
                         v_str="Example description",
                     ),