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

Cloud Trace exporter #698

Merged
merged 12 commits into from
Jun 4, 2020

Conversation

AndrewAXue
Copy link
Contributor

@AndrewAXue AndrewAXue commented May 15, 2020

Addresses #287.
Adding a Cloud Trace (formerly known as stackdriver) trace exporter.

@AndrewAXue AndrewAXue requested a review from a team May 15, 2020 20:40
@AndrewAXue AndrewAXue force-pushed the stackdriver_exporter branch 3 times, most recently from f789229 to 94c206f Compare May 19, 2020 16:20
Copy link
Contributor

@sjbrunst sjbrunst left a comment

Choose a reason for hiding this comment

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

Quick initial pass on cloud_trace/init.py

@kintel
Copy link

kintel commented May 20, 2020

Quick notes from offline discussion:

@AndrewAXue AndrewAXue removed the request for review from a team May 20, 2020 17:50
@AndrewAXue AndrewAXue changed the title Stackdriver exporter [WIP] Cloud Trace exporter May 20, 2020
@AndrewAXue AndrewAXue force-pushed the stackdriver_exporter branch from b276f0a to 124081b Compare May 20, 2020 19:14
Copy link
Member

@c24t c24t left a comment

Choose a reason for hiding this comment

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

One blocking comment about Span-valued span parents, some questions about client types, and some non-blocking nits.

I'll have to take another pass at the examples, but this looks like a great start otherwise. Thanks for picking this up @AndrewAXue!

# pylint: disable=broad-except
except Exception as ex:
logger.warning("Error while writing to Cloud Trace: %s", ex)
return SpanExportResult.FAILURE
Copy link
Contributor

Choose a reason for hiding this comment

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

Not specific to this PR but should SpanExportResult be able to encapsulate other error information like the original exception? If all exporters try to catch and swallow every exception globally and then return just one value to represent failure, we might be losing out on valuable information. Perhaps processor/exporter should be able to return the original python exceptions or error messages+stack traces along with a failure status. This information can be used by the caller to show helpful error messages to users by utilizing a single global error handler instead of relying on every processor to do the right thing by using the correct logger. In general, I feel error handling should propagate back up and be taken care of preferably in a single place. Especially if we are catching all possible exceptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with you, but I would prefer to handle that in a seperate PR :)

Copy link
Contributor

Choose a reason for hiding this comment

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

For sure, I'm not suggesting you change it in this PR but wanted to bring this up for the Python group in general.

Copy link
Member

Choose a reason for hiding this comment

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

I agree, although in this case hopefully the logger.warning helps.

@kintel
Copy link

kintel commented May 26, 2020

One structural question: The majority of the code lives in init.py. This strikes me as an odd choice. Is there a reason for this, e.g. is there a style guide that prefers using init.py in certain cases?

@AndrewAXue AndrewAXue force-pushed the stackdriver_exporter branch 2 times, most recently from e0baf7a to 25cdf3e Compare May 27, 2020 21:18
Copy link

@kintel kintel left a comment

Choose a reason for hiding this comment

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

Before merging, we should create a minimal example, which can be manually run to sanity-check the exporter. I quickly tried to shoehorn this into an existing program, but got this error:

Error while writing to Cloud Trace: list indices must be integers or slices, not str
Error 'TruncatableString' object is not iterable when creating span

@kintel
Copy link

kintel commented May 27, 2020

Oh, and for any issues, comments or suggestions that we decide not to address right now, please open an issue in https://github.com/GoogleCloudPlatform/opentelemetry-operations-python, and link it here.

@AndrewAXue
Copy link
Contributor Author

Before merging, we should create a minimal example, which can be manually run to sanity-check the exporter. I quickly tried to shoehorn this into an existing program, but got this error:

Error while writing to Cloud Trace: list indices must be integers or slices, not str
Error 'TruncatableString' object is not iterable when creating span

Hey Marius, there are examples in opentelemetry-ext-cloud-trace/examples. One of which is just a basic trace, the 2nd and 3rd are example server + clients. Can you send me the exact code you tried to use this exporter in?

@kintel
Copy link

kintel commented May 28, 2020

Taking the credentials/test environment discussion offline for debugging (I see similar issues with the examples in my env).

@AndrewAXue AndrewAXue force-pushed the stackdriver_exporter branch from cad4252 to 0a145fa Compare May 28, 2020 18:49
Copy link

@kintel kintel left a comment

Choose a reason for hiding this comment

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

Hi Andrew, I did a relatively thorough review, focusing mostly on the Trace API interaction.
Left a handful of comments.
As usual, feel free to defer comments to a later PRs upon creating appropriate GitHub issues.

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! There's a few blocking comments for me. The major sticking point to me is the modification of a vendor-agnostic instrumentation specifically for cloud trace. Maybe we can discuss further here or through gitter on a solution there.

docs/examples/cloud_trace_exporter/client.py Outdated Show resolved Hide resolved
docs/examples/cloud_trace_exporter/server.py Outdated Show resolved Hide resolved
everything.sh Outdated Show resolved Hide resolved
everything.sh Outdated Show resolved Hide resolved
ext/opentelemetry-ext-cloud-trace/README.rst Outdated Show resolved Hide resolved
opentelemetry-sdk/CHANGELOG.md Outdated Show resolved Hide resolved
@AndrewAXue AndrewAXue force-pushed the stackdriver_exporter branch from a131d1a to 002279b Compare May 29, 2020 22:14
@AndrewAXue AndrewAXue force-pushed the stackdriver_exporter branch 2 times, most recently from 4b5d631 to 249beb4 Compare June 1, 2020 16:58
@AndrewAXue AndrewAXue requested review from toumorokoshi and c24t June 1, 2020 17:39
@c24t
Copy link
Member

c24t commented Jun 2, 2020

@AndrewAXue FYI force pushing breaks github's inline code comments (among other problems). Since we're squash-merging PRs anyway there's usually not much reason to force-push, and it makes reviewers' lives easier if you don't.

Copy link
Member

@c24t c24t left a comment

Choose a reason for hiding this comment

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

A few questions, but no more blocking comments from me. Thanks @AndrewAXue!

@c24t
Copy link
Member

c24t commented Jun 2, 2020

@toumorokoshi if this LGTY it should be ready to merge.

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.

Great, thanks!

dropped_links = len(links) - MAX_NUM_LINKS
links = links[:MAX_NUM_LINKS]
for link in links:
if len(link.attributes) > MAX_LINK_ATTRS:
Copy link
Member

Choose a reason for hiding this comment

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

this chunk of code (along with the warning) could be refactored into _extract_attributes.

I see some boilerplate here and extract_events that includes the max check then logs a warning. This feels intuitive to me to put the warning around some attributes will be dropped into the _extract_attributes itself, or maybe even the BoundedDict itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey Yusuke, so I also noticed that the max length check + warning is repeated in extract_events and extract_links. The reason I kept it that way is so I can print more informative warnings then just "Too many attributes, dropped some", doing it this way I can say which event or link had too many attributes.

Copy link
Member

Choose a reason for hiding this comment

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

sounds good, although it feels like that's still achievable after a refactor.

@AndrewAXue AndrewAXue force-pushed the stackdriver_exporter branch from 7506644 to a0ffad6 Compare June 3, 2020 17:22
Andrew Xue added 2 commits June 3, 2020 14:04
@toumorokoshi toumorokoshi merged commit c42749a into open-telemetry:master Jun 4, 2020
@AndrewAXue AndrewAXue deleted the stackdriver_exporter branch June 4, 2020 15:59
toumorokoshi pushed a commit to toumorokoshi/opentelemetry-python that referenced this pull request Jun 5, 2020
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.

7 participants