Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add status to the tags for the Zipkin Exporter #1124

Merged
merged 9 commits into from
Sep 18, 2020
2 changes: 2 additions & 0 deletions exporter/opentelemetry-exporter-zipkin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
([#1097](https://github.com/open-telemetry/opentelemetry-python/pull/1097))
- Drop support for Python 3.4
([#1099](https://github.com/open-telemetry/opentelemetry-python/pull/1099))
- Add status mapping to tags
([#1111](https://github.com/open-telemetry/opentelemetry-python/issues/1111))

## Version 0.12b0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"][
"ot.status_code"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - these tags don't quite look correct because they're ot. The referenced spec was added several months ago (open-telemetry/opentelemetry-specification#380) before the acronym was officially finalized as otel. I have sent open-telemetry/opentelemetry-specification#967 to fix this.

I'd recommend either proactively using otel (it's pretty obvious that's what it should be, see lines 180 / 183 in this file) or waiting a bit if you'd like to see the update in the spec merged. As it stands, if this merges it'll need to be updated right away anyways.

] = span.status.canonical_code.value
if span.status.description is not None:
zipkin_span["tags"][
"ot.status_description"
] = span.status.description

if context.trace_flags.sampled:
zipkin_span["debug"] = True

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -213,6 +217,8 @@ def test_export(self):
"key_bool": "False",
"key_string": "hello_world",
"key_float": "111.22",
"ot.status_code": 2,
"ot.status_description": "Example description",
},
"annotations": [
{
Expand All @@ -231,7 +237,7 @@ def test_export(self):
"duration": durations[1] // 10 ** 3,
"localEndpoint": local_endpoint,
"kind": None,
"tags": {"key_resource": "some_resource"},
"tags": {"key_resource": "some_resource", "ot.status_code": 0},
"annotations": None,
},
{
Expand All @@ -245,6 +251,7 @@ def test_export(self):
"tags": {
"key_string": "hello_world",
"key_resource": "some_resource",
"ot.status_code": 0,
},
"annotations": None,
},
Expand All @@ -259,6 +266,7 @@ def test_export(self):
"tags": {
"otel.instrumentation_library.name": "name",
"otel.instrumentation_library.version": "version",
"ot.status_code": 0,
},
"annotations": None,
},
Expand Down Expand Up @@ -324,7 +332,7 @@ def test_zero_padding(self):
"duration": duration // 10 ** 3,
"localEndpoint": local_endpoint,
"kind": None,
"tags": {},
"tags": {"ot.status_code": 0},
"annotations": None,
"debug": True,
"parentId": "0aaaaaaaaaaaaaaa",
Expand Down