Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ended when exiting the context manager.
Args:
span: The span to start and make current.
end_on_exit: Whether to end the span automatically when leaving the
context manager.
"""
# pylint: disable=unused-argument,no-self-use
yield
# Once https://github.com/python/mypy/issues/7092 is resolved,
# the following type definition should be replaced with
# from opentelemetry.util.loader import ImplementationFactory
ImplementationFactory = typing.Callable[
[typing.Type[TracerSource]], typing.Optional[TracerSource]
]
_TRACER_SOURCE = None # type: typing.Optional[TracerSource]
_TRACER_SOURCE_FACTORY = None # type: typing.Optional[ImplementationFactory]
def tracer_source() -> TracerSource:
"""Gets the current global :class:`~.TracerSource` object.
If there isn't one set yet, a default will be loaded.
"""
global _TRACER_SOURCE, _TRACER_SOURCE_FACTORY # pylint:disable=global-statement
if _TRACER_SOURCE is None:
# pylint:disable=protected-access
_TRACER_SOURCE = loader._load_impl(
def tracer_source() -> TracerSource:
"""Gets the current global :class:`~.TracerSource` object.
If there isn't one set yet, a default will be loaded.
"""
global _TRACER_SOURCE, _TRACER_SOURCE_FACTORY # pylint:disable=global-statement
if _TRACER_SOURCE is None:
# pylint:disable=protected-access
_TRACER_SOURCE = loader._load_impl(
TracerSource, _TRACER_SOURCE_FACTORY
)
del _TRACER_SOURCE_FACTORY
return _TRACER_SOURCE