You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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()
defget_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.
The text was updated successfully, but these errors were encountered:
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:
The current
execution_context
implementation is hardcoded to use a thread local implementation. Applications running under different threading paradigms, such asasyncio
ortornado, 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.:where the
ThreadLocalExecutionContextDelegate
is just an implementation of the existingexecution_context
methods. The configuration for the delegate class could either be set directly on theexecution_context
object (although having a stateful configuration method on the class seems like an anti-pattern) or by introducing a global configuration object likeconfig_integration
.Happy to submit a PR with feedback on the approach.
The text was updated successfully, but these errors were encountered: