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

Allow for pluggable execution_context implementations #433

Closed
ewhauser opened this issue Dec 23, 2018 · 3 comments
Closed

Allow for pluggable execution_context implementations #433

ewhauser opened this issue Dec 23, 2018 · 3 comments

Comments

@ewhauser
Copy link
Contributor

The current execution_context implementation is hardcoded to use a thread local implementation. Applications running under different threading paradigms, such as asyncio or tornado, require a different context implementation. The only current option available to extend is to monkeypatch the execution_context`.

In order to provide for extensibility, the execution_context could delegate it's method calls to a pluggable implementation, i.e.:

_execution_context_delegate = ThreadLocalExecutionContextDelegate()

def get_opencensus_tracer():
    """Get the opencensus tracer from thread local."""
    return _execution_context_manager.get_opencensus_tracer()

where the ThreadLocalExecutionContextDelegate is just an implementation of the existing execution_context methods. The configuration for the delegate class could either be set directly on the execution_context object (although having a stateful configuration method on the class seems like an anti-pattern) or by introducing a global configuration object like config_integration.

Happy to submit a PR with feedback on the approach.

@ewhauser
Copy link
Contributor Author

This is related to #234.

@ewhauser ewhauser reopened this Jan 13, 2019
@ewhauser
Copy link
Contributor Author

The current approach I've taken abstracted out the retrieval of the storage of the current tracer into a method and monkey patch that method depending on the host environment:

https://github.com/dronedeploy/opencensus-python/blob/master/opencensus/trace/execution_context.py#L22

@c24t
Copy link
Member

c24t commented Apr 1, 2019

#588 should fix this.

@c24t c24t closed this as completed Apr 1, 2019
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

No branches or pull requests

2 participants