def tracer_provider() -> TracerProvider: """Gets the current global :class:`~.TracerProvider` object. If there isn't one set yet, a default will be loaded. """ global _TRACER_PROVIDER, _TRACER_PROVIDER_FACTORY # pylint:disable=global-statement if _TRACER_PROVIDER is None: # pylint:disable=protected-access try: _TRACER_PROVIDER = loader._load_impl( TracerProvider, _TRACER_PROVIDER_FACTORY # type: ignore ) except TypeError: # if we raised an exception trying to instantiate an # abstract class, default to no-op tracer impl logger.warning( "Unable to instantiate TracerProvider from factory.", exc_info=True, ) _TRACER_PROVIDER = DefaultTracerProvider() del _TRACER_PROVIDER_FACTORY return _TRACER_PROVIDER
def meter() -> Meter: """Gets the current global :class:`~.Meter` object. If there isn't one set yet, a default will be loaded. """ global _METER, _METER_FACTORY # pylint:disable=global-statement if _METER is None: # pylint:disable=protected-access _METER = loader._load_impl(Meter, _METER_FACTORY) del _METER_FACTORY return _METER
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