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

ext/jaeger - Transform resource to tags when exporting #645

Merged
merged 9 commits into from
May 19, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ def _translate_to_jaeger(spans: Span):
parent_id = span.parent.span_id if span.parent else 0

tags = _extract_tags(span.attributes)
if span.resource:
tags.extend(_extract_tags(span.resource.labels))

tags.extend(
[
Expand Down
9 changes: 9 additions & 0 deletions ext/opentelemetry-ext-jaeger/tests/test_jaeger_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from opentelemetry import trace as trace_api
from opentelemetry.ext.jaeger.gen.jaeger import ttypes as jaeger
from opentelemetry.sdk import trace
from opentelemetry.sdk.trace import Resource
from opentelemetry.trace.status import Status, StatusCanonicalCode


Expand Down Expand Up @@ -199,6 +200,9 @@ def test_translate_to_jaeger(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].resource = Resource(
labels={"key_resource": "some_resource"}
)
otel_spans[0].set_status(
Status(StatusCanonicalCode.UNKNOWN, "Example description")
)
Expand Down Expand Up @@ -237,6 +241,11 @@ def test_translate_to_jaeger(self):
vType=jaeger.TagType.DOUBLE,
vDouble=111.22,
),
jaeger.Tag(
key="key_resource",
vType=jaeger.TagType.STRING,
vStr="some_resource",
),
jaeger.Tag(
key="status.code",
vType=jaeger.TagType.LONG,
Expand Down