diff --git a/opentelemetry-api/src/opentelemetry/metrics/__init__.py b/opentelemetry-api/src/opentelemetry/metrics/__init__.py index 90f2f03f56b..d7bd8e3680d 100644 --- a/opentelemetry-api/src/opentelemetry/metrics/__init__.py +++ b/opentelemetry-api/src/opentelemetry/metrics/__init__.py @@ -462,7 +462,8 @@ def set_meter_provider(meter_provider: MeterProvider) -> None: global _METER_PROVIDER # pylint: disable=global-statement if _METER_PROVIDER is not None: - logger.warning("Overriding current MeterProvider") + logger.warning("Overriding of current MeterProvider is not allowed") + return _METER_PROVIDER = meter_provider diff --git a/opentelemetry-api/src/opentelemetry/trace/__init__.py b/opentelemetry-api/src/opentelemetry/trace/__init__.py index 9fe728fb6a8..6be3dd5a558 100644 --- a/opentelemetry-api/src/opentelemetry/trace/__init__.py +++ b/opentelemetry-api/src/opentelemetry/trace/__init__.py @@ -77,7 +77,6 @@ from contextlib import contextmanager from logging import getLogger -from opentelemetry.configuration import Configuration from opentelemetry.trace.propagation import ( get_current_span, set_span_in_context, @@ -483,4 +482,5 @@ def get_tracer_provider() -> TracerProvider: "get_tracer_provider", "set_tracer_provider", "set_span_in_context", + "Status", ] diff --git a/opentelemetry-api/tests/metrics/test_globals.py b/opentelemetry-api/tests/metrics/test_globals.py index 9b9cfb94d90..513dd7dd2df 100644 --- a/opentelemetry-api/tests/metrics/test_globals.py +++ b/opentelemetry-api/tests/metrics/test_globals.py @@ -16,8 +16,8 @@ def test_meter_provider_override_warning(self): test.output, [ ( - "WARNING:opentelemetry.metrics:Overriding current " - "MeterProvider" + "WARNING:opentelemetry.metrics:Overriding of current " + "MeterProvider is not allowed" ) ], )