-
Notifications
You must be signed in to change notification settings - Fork 657
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
Changes from 8 commits
91db3cd
d756f58
1d20465
82e103a
7d4ba99
12da24a
007165e
6559eec
3127e73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
||
|
@@ -34,7 +35,9 @@ def setUp(self): | |
is_remote=False, | ||
) | ||
|
||
self._test_span = trace.Span("test_span", context=context) | ||
self._test_span = trace.Span( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you always attach an empty resource by default, you're omitting the valid test case of a Span with "None" as the resource. For the purposes of this PR, I recommend adding a case that assumes the Span.resource may be None. Added #702 for a more global fix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for reviewing @toumorokoshi, I made the requested changes. |
||
"test_span", context=context, resource=Resource.create_empty() | ||
) | ||
self._test_span.start() | ||
self._test_span.end() | ||
|
||
|
@@ -189,16 +192,27 @@ def test_translate_to_jaeger(self): | |
kind=trace_api.SpanKind.CLIENT, | ||
), | ||
trace.Span( | ||
name=span_names[1], context=parent_context, parent=None | ||
name=span_names[1], | ||
context=parent_context, | ||
parent=None, | ||
resource=Resource.create_empty(), | ||
), | ||
trace.Span( | ||
name=span_names[2], | ||
context=other_context, | ||
parent=None, | ||
resource=Resource.create_empty(), | ||
), | ||
trace.Span(name=span_names[2], context=other_context, parent=None), | ||
] | ||
|
||
otel_spans[0].start(start_time=start_times[0]) | ||
# added here to preserve order | ||
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") | ||
) | ||
|
@@ -237,6 +251,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, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this necessary? feels like it adds conditional logic for a very nominal (maybe 500ns on a modern processor at most) improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also I don't believe this is completely correct. Currently in the SDK, the Span.resource attribute can be None as well.
This can be simplified to a Falsy check (
if span.resource
) to cover both cases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so I'm gonna revert the exposing of
EMPTY_RESOURCE
and just make the simple Falsy check.@mauriciovasquezbernal, are you ok with that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm ok with that, sorry for the confusion.