Skip to content

Commit

Permalink
Update Jaeger exporter status code (#1488)
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv authored Jan 7, 2021
1 parent eb7125d commit cd39fc1
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 49 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `opentelemetry-exporter-otlp` Headers are now passed in as tuple as metadata, instead of a
string, which was incorrect.
([#1507](https://github.com/open-telemetry/opentelemetry-python/pull/1507))
- `opentelemetry-exporter-jaeger` Updated Jaeger exporter status code tag
([#1488](https://github.com/open-telemetry/opentelemetry-python/pull/1488))

## [0.16b1](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.16b1) - 2020-11-26
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
),
Expand Down Expand Up @@ -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",
),
Expand Down Expand Up @@ -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",
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
),
Expand Down Expand Up @@ -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",
),
Expand Down

0 comments on commit cd39fc1

Please sign in to comment.