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

Batch exporting spans once a while #63

Merged
merged 25 commits into from
Nov 16, 2017

Conversation

liyanhui1228
Copy link
Contributor

@liyanhui1228 liyanhui1228 commented Nov 3, 2017

Closes #59
This PR is doing the following things:

  • Add background transport module for batch exporting spans, one thread per exporter.
  • Add sync transport module for exporting span once it's finished

@liyanhui1228 liyanhui1228 changed the title Batch exporting spans once a while [WIP] Batch exporting spans once a while Nov 3, 2017
@liyanhui1228 liyanhui1228 changed the title [WIP] Batch exporting spans once a while Batch exporting spans once a while Nov 3, 2017

def export(self, trace):
def emit(self, trace):
Copy link

Choose a reason for hiding this comment

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

Can you add emit() to base.Exporter, and add doc comments explaining emit() and export()?

The naming is a little weird, since I don't usually think of "transport" for something that's just printing or appending to a file. But I don't have a better suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.



class _Worker(object):
def __init__(self, exporter, grace_period=_DEFAULT_GRACE_PERIOD,
Copy link

Choose a reason for hiding this comment

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

The google-cloud-python code which inspired this is well documented, e.g. https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/logging/google/cloud/logging/handlers/transports/background_thread.py#L65 . Can you write/copy doc comments into this code to match?

It would be nicest if we could both use the same code, but I don't think that's feasible right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -62,12 +63,14 @@ def __init__(
service_name='my_service',
host_name=DEFAULT_HOST_NAME,
port=DEFAULT_PORT,
endpoint=DEFAULT_ENDPOINT):
endpoint=DEFAULT_ENDPOINT,
transport=sync.SyncTransport):
Copy link

Choose a reason for hiding this comment

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

Can you update the doc comment above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

from opencensus.trace.exporters.transports import background_thread
exporter = stackdriver_exporter.StackdriverExporter(
transport=background_thread.BackgroundThreadTransport)

Copy link

Choose a reason for hiding this comment

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

To check my understanding, the flask test uses async transport and the django test uses sync transport? I think this is a good idea, but we should add a comment here and in the django test explaining that they are intentionally different to test both code paths.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes correct. Comment added.

@liyanhui1228 liyanhui1228 merged commit b106545 into census-instrumentation:master Nov 16, 2017
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

2 participants