-
Notifications
You must be signed in to change notification settings - Fork 653
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/Zipkin - Transform resource to tags when exporting #707
ext/Zipkin - Transform resource to tags when exporting #707
Conversation
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.
Thanks for the PR! I think there's a few code improvements that can be made here, see comments.
@@ -212,6 +212,17 @@ def _extract_tags_from_span(attr): | |||
return tags | |||
|
|||
|
|||
def _extract_tags_from_span(span: Span): | |||
tags = _extract_tags_from_dict(span.attributes) |
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.
there are cases where a DefaultSpan is used instead of an sdk.trace.Span. In those cases this will return an attributeerror as "attributes" doesn't exist.
There may need to be some sort of getter for attributes in the API itself to ensure this works as expected.
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.
Can you elaborate on how I should handle this?
Currently I kept the existing behavior.
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.
Right, this was a bug that existed in the current implementation of the exporter. You'd want to use something like getattr(span, "attributes", None)
to prevent an exception from being raised.
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.
Thanks for clarifying! Changed to getattr
.
ext/opentelemetry-ext-zipkin/src/opentelemetry/ext/zipkin/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-zipkin/src/opentelemetry/ext/zipkin/__init__.py
Outdated
Show resolved
Hide resolved
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.
Thanks for adding this, looking at the code, there are a few places that are making the assumption that a span has an attributes
attribute, I've created the issue here to track the work: #715
@@ -212,6 +212,17 @@ def _extract_tags_from_span(attr): | |||
return tags | |||
|
|||
|
|||
def _extract_tags_from_span(span: Span): | |||
tags = _extract_tags_from_dict(span.attributes) |
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.
Right, this was a bug that existed in the current implementation of the exporter. You'd want to use something like getattr(span, "attributes", None)
to prevent an exception from being raised.
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.
LGTM! Thanks for addressing my concerns.
Thanks! |
This PR implements the missing part of exporting the TraceProvider resource into Zipkin.
Same as in js.
This PR also aligns Zipkin behavior with my previous PR done to jaeger - #645.
I wanted to preserve the existing behavior of the
tags
beingNone
if attributes do not exist, so I ended with a nestedif
, although I think it's worth discussing maybe the default value should always be{}
.As for the test, I added another span to cover all tags permutations: