How to use the opentelemetry-api.src.opentelemetry.trace.__init__.TracerSource function in opentelemetry-api

To help you get started, we’ve selected a few opentelemetry-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github open-telemetry / opentelemetry-python / opentelemetry-api / src / opentelemetry / trace / __init__.py View on Github external
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(
github open-telemetry / opentelemetry-python / opentelemetry-api / src / opentelemetry / trace / __init__.py View on Github external
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

opentelemetry-api

OpenTelemetry Python API

Apache-2.0
Latest version published 14 days ago

Package Health Score

97 / 100
Full package analysis