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/Zipkin - Transform resource to tags when exporting #707

Merged
merged 10 commits into from
May 22, 2020

Conversation

nirsky
Copy link
Contributor

@nirsky nirsky commented May 19, 2020

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 being None if attributes do not exist, so I ended with a nested if, 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:

  1. Span only has attributes.
  2. Span only has resource.
  3. Span has both resource and attributes.
  4. Span doesn't have either.

@nirsky nirsky requested a review from a team as a code owner May 19, 2020 10:12
Copy link
Member

@toumorokoshi toumorokoshi left a 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)
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@codeboten codeboten left a 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)
Copy link
Contributor

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.

@nirsky nirsky requested a review from toumorokoshi May 21, 2020 07:59
Copy link
Member

@toumorokoshi toumorokoshi left a 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.

@toumorokoshi toumorokoshi merged commit 97b7c22 into open-telemetry:master May 22, 2020
@toumorokoshi
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants