Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Allow for pluggable execution_context implementations #433

@ewhauser

Description

@ewhauser

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions