diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bfc60619de..f1993e316df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.11.1-0.30b1...HEAD) +- Make metrics components public + ([#2684](https://github.com/open-telemetry/opentelemetry-python/pull/2684)) - Update to semantic conventions v1.11.0 ([#2669](https://github.com/open-telemetry/opentelemetry-python/pull/2669)) - Update opentelemetry-proto to v0.17.0 diff --git a/docs/api/metrics.rst b/docs/api/metrics.rst index 4fd464ae1d7..93a8cbe7208 100644 --- a/docs/api/metrics.rst +++ b/docs/api/metrics.rst @@ -1,12 +1,5 @@ -opentelemetry._metrics package -============================== - -.. warning:: - OpenTelemetry Python metrics are in an experimental state. The APIs within - :mod:`opentelemetry._metrics` are subject to change in minor/patch releases and make no - backward compatability guarantees at this time. - - Once metrics become stable, this package will be be renamed to ``opentelemetry.metrics``. +opentelemetry.metrics package +============================= .. toctree:: @@ -14,4 +7,4 @@ opentelemetry._metrics package Module contents --------------- -.. automodule:: opentelemetry._metrics +.. automodule:: opentelemetry.metrics diff --git a/docs/conf.py b/docs/conf.py index 3472ff507c0..55b1af7331b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -99,11 +99,11 @@ ("py:class", "ValueT"), ( "py:class", - "opentelemetry.sdk._metrics._internal.instrument._Synchronous", + "opentelemetry.sdk.metrics._internal.instrument._Synchronous", ), ( "py:class", - "opentelemetry.sdk._metrics._internal.instrument._Asynchronous", + "opentelemetry.sdk.metrics._internal.instrument._Asynchronous", ), # Even if wrapt is added to intersphinx_mapping, sphinx keeps failing # with "class reference target not found: ObjectProxy". diff --git a/docs/examples/metrics/README.rst b/docs/examples/metrics/README.rst index 2a9bb70318b..50e80a945e1 100644 --- a/docs/examples/metrics/README.rst +++ b/docs/examples/metrics/README.rst @@ -1,11 +1,6 @@ OpenTelemetry Metrics SDK ========================= -.. warning:: - OpenTelemetry Python metrics are in an experimental state. The APIs within - :mod:`opentelemetry.sdk._metrics` are subject to change in minor/patch releases and there are no - backward compatability guarantees at this time. - Start the Collector locally to see data being exported. Write the following file: .. code-block:: yaml @@ -45,4 +40,4 @@ The resulting metrics will appear in the output from the collector and look simi .. code-block:: sh -TODO \ No newline at end of file +TODO diff --git a/docs/examples/metrics/example.py b/docs/examples/metrics/example.py index 9843d659534..fde20308a21 100644 --- a/docs/examples/metrics/example.py +++ b/docs/examples/metrics/example.py @@ -1,16 +1,16 @@ from typing import Iterable -from opentelemetry._metrics import ( +from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import ( + OTLPMetricExporter, +) +from opentelemetry.metrics import ( + CallbackOptions, Observation, get_meter_provider, set_meter_provider, ) -from opentelemetry._metrics._internal.instrument import CallbackOptions -from opentelemetry.exporter.otlp.proto.grpc._metric_exporter import ( - OTLPMetricExporter, -) -from opentelemetry.sdk._metrics import MeterProvider -from opentelemetry.sdk._metrics.export import PeriodicExportingMetricReader +from opentelemetry.sdk.metrics import MeterProvider +from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader exporter = OTLPMetricExporter(insecure=True) reader = PeriodicExportingMetricReader(exporter) diff --git a/docs/getting_started/metrics_example.py b/docs/getting_started/metrics_example.py index 32342e72122..83c9a1b8c45 100644 --- a/docs/getting_started/metrics_example.py +++ b/docs/getting_started/metrics_example.py @@ -17,14 +17,14 @@ from typing import Iterable -from opentelemetry._metrics import ( +from opentelemetry.metrics import ( CallbackOptions, Observation, get_meter_provider, set_meter_provider, ) -from opentelemetry.sdk._metrics import MeterProvider -from opentelemetry.sdk._metrics.export import ( +from opentelemetry.sdk.metrics import MeterProvider +from opentelemetry.sdk.metrics.export import ( ConsoleMetricExporter, PeriodicExportingMetricReader, ) diff --git a/docs/sdk/metrics.export.rst b/docs/sdk/metrics.export.rst index 775c0a66111..0c0efaaf911 100644 --- a/docs/sdk/metrics.export.rst +++ b/docs/sdk/metrics.export.rst @@ -1,7 +1,7 @@ -opentelemetry.sdk._metrics.export -================================= +opentelemetry.sdk.metrics.export +================================ -.. automodule:: opentelemetry.sdk._metrics.export +.. automodule:: opentelemetry.sdk.metrics.export :members: :undoc-members: :show-inheritance: diff --git a/docs/sdk/metrics.rst b/docs/sdk/metrics.rst index 1bef70185ee..28f33f097cd 100644 --- a/docs/sdk/metrics.rst +++ b/docs/sdk/metrics.rst @@ -1,13 +1,6 @@ -opentelemetry.sdk._metrics package +opentelemetry.sdk.metrics package ================================== -.. warning:: - OpenTelemetry Python metrics are in an experimental state. The APIs within - :mod:`opentelemetry.sdk._metrics` are subject to change in minor/patch releases and there are no - backward compatability guarantees at this time. - - Once metrics become stable, this package will be be renamed to ``opentelemetry.sdk.metrics``. - Submodules ---------- @@ -16,7 +9,7 @@ Submodules metrics.export metrics.view -.. automodule:: opentelemetry.sdk._metrics +.. automodule:: opentelemetry.sdk.metrics :members: :undoc-members: :show-inheritance: diff --git a/docs/sdk/metrics.view.rst b/docs/sdk/metrics.view.rst index b18754177aa..d7fa96b2356 100644 --- a/docs/sdk/metrics.view.rst +++ b/docs/sdk/metrics.view.rst @@ -1,7 +1,7 @@ -opentelemetry.sdk._metrics.view -=============================== +opentelemetry.sdk.metrics.view +============================== -.. automodule:: opentelemetry.sdk._metrics.view +.. automodule:: opentelemetry.sdk.metrics.view :members: :undoc-members: :show-inheritance: diff --git a/exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/_metric_exporter/__init__.py b/exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/metric_exporter/__init__.py similarity index 98% rename from exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/_metric_exporter/__init__.py rename to exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/metric_exporter/__init__.py index 902f683e7b1..83846da81fc 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/_metric_exporter/__init__.py +++ b/exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/metric_exporter/__init__.py @@ -30,14 +30,14 @@ from opentelemetry.sdk.environment_variables import ( OTEL_EXPORTER_OTLP_METRICS_INSECURE, ) -from opentelemetry.sdk._metrics.export import ( +from opentelemetry.sdk.metrics.export import ( Gauge, Histogram, Metric, Sum, ) -from opentelemetry.sdk._metrics.export import ( +from opentelemetry.sdk.metrics.export import ( MetricExporter, MetricExportResult, MetricsData, diff --git a/exporter/opentelemetry-exporter-otlp-proto-grpc/tests/metrics/test_otlp_metrics_exporter.py b/exporter/opentelemetry-exporter-otlp-proto-grpc/tests/metrics/test_otlp_metrics_exporter.py index 009e1d2de55..0d4418030ba 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-grpc/tests/metrics/test_otlp_metrics_exporter.py +++ b/exporter/opentelemetry-exporter-otlp-proto-grpc/tests/metrics/test_otlp_metrics_exporter.py @@ -20,7 +20,7 @@ from google.rpc.error_details_pb2 import RetryInfo from grpc import StatusCode, server -from opentelemetry.exporter.otlp.proto.grpc._metric_exporter import ( +from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import ( OTLPMetricExporter, ) from opentelemetry.proto.collector.metrics.v1.metrics_service_pb2 import ( @@ -40,7 +40,10 @@ from opentelemetry.proto.resource.v1.resource_pb2 import ( Resource as OTLPResource, ) -from opentelemetry.sdk._metrics.export import ( +from opentelemetry.sdk.environment_variables import ( + OTEL_EXPORTER_OTLP_METRICS_INSECURE, +) +from opentelemetry.sdk.metrics.export import ( AggregationTemporality, Histogram, HistogramDataPoint, @@ -50,9 +53,6 @@ ResourceMetrics, ScopeMetrics, ) -from opentelemetry.sdk.environment_variables import ( - OTEL_EXPORTER_OTLP_METRICS_INSECURE, -) from opentelemetry.sdk.resources import Resource from opentelemetry.sdk.util.instrumentation import ( InstrumentationScope as SDKInstrumentationScope, @@ -303,7 +303,7 @@ def tearDown(self): ) @patch("opentelemetry.exporter.otlp.proto.grpc.exporter.secure_channel") @patch( - "opentelemetry.exporter.otlp.proto.grpc._metric_exporter.OTLPMetricExporter._stub" + "opentelemetry.exporter.otlp.proto.grpc.metric_exporter.OTLPMetricExporter._stub" ) # pylint: disable=unused-argument def test_no_credentials_error( diff --git a/exporter/opentelemetry-exporter-otlp/tests/test_otlp.py b/exporter/opentelemetry-exporter-otlp/tests/test_otlp.py index 57b3d7b1b12..5b574a9d603 100644 --- a/exporter/opentelemetry-exporter-otlp/tests/test_otlp.py +++ b/exporter/opentelemetry-exporter-otlp/tests/test_otlp.py @@ -17,7 +17,7 @@ from opentelemetry.exporter.otlp.proto.grpc._log_exporter import ( OTLPLogExporter, ) -from opentelemetry.exporter.otlp.proto.grpc._metric_exporter import ( +from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import ( OTLPMetricExporter, ) from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import ( diff --git a/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/__init__.py b/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/__init__.py index 13032e319e6..ac1ea58c660 100644 --- a/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/__init__.py +++ b/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/__init__.py @@ -29,9 +29,9 @@ from prometheus_client import start_http_server - from opentelemetry._metrics import get_meter_provider, set_meter_provider from opentelemetry.exporter.prometheus import PrometheusMetricReader - from opentelemetry.sdk._metrics import MeterProvider + from opentelemetry.metrics import get_meter_provider, set_meter_provider + from opentelemetry.sdk.metrics import MeterProvider # Start Prometheus client start_http_server(port=8000, addr="localhost") @@ -77,7 +77,7 @@ ) from prometheus_client.core import Metric as PrometheusMetric -from opentelemetry.sdk._metrics.export import ( +from opentelemetry.sdk.metrics.export import ( Gauge, Histogram, HistogramDataPoint, diff --git a/exporter/opentelemetry-exporter-prometheus/tests/test_prometheus_exporter.py b/exporter/opentelemetry-exporter-prometheus/tests/test_prometheus_exporter.py index 9ad3a692474..4b6118bdab1 100644 --- a/exporter/opentelemetry-exporter-prometheus/tests/test_prometheus_exporter.py +++ b/exporter/opentelemetry-exporter-prometheus/tests/test_prometheus_exporter.py @@ -23,7 +23,7 @@ PrometheusMetricReader, _CustomCollector, ) -from opentelemetry.sdk._metrics.export import ( +from opentelemetry.sdk.metrics.export import ( AggregationTemporality, Histogram, HistogramDataPoint, diff --git a/opentelemetry-api/src/opentelemetry/environment_variables.py b/opentelemetry-api/src/opentelemetry/environment_variables.py index 0810acc5ff0..5c5a9b3c4aa 100644 --- a/opentelemetry-api/src/opentelemetry/environment_variables.py +++ b/opentelemetry-api/src/opentelemetry/environment_variables.py @@ -49,7 +49,7 @@ .. envvar:: OTEL_PYTHON_TRACER_PROVIDER """ -_OTEL_PYTHON_METER_PROVIDER = "OTEL_PYTHON_METER_PROVIDER" +OTEL_PYTHON_METER_PROVIDER = "OTEL_PYTHON_METER_PROVIDER" """ .. envvar:: OTEL_PYTHON_METER_PROVIDER """ diff --git a/opentelemetry-api/src/opentelemetry/_metrics/__init__.py b/opentelemetry-api/src/opentelemetry/metrics/__init__.py similarity index 92% rename from opentelemetry-api/src/opentelemetry/_metrics/__init__.py rename to opentelemetry-api/src/opentelemetry/metrics/__init__.py index c205adde0b7..0de88ccdaa7 100644 --- a/opentelemetry-api/src/opentelemetry/_metrics/__init__.py +++ b/opentelemetry-api/src/opentelemetry/metrics/__init__.py @@ -30,15 +30,16 @@ The following code shows how to obtain a meter using the global :class:`.MeterProvider`:: - from opentelemetry._metrics import get_meter + from opentelemetry.metrics import get_meter meter = get_meter("example-meter") counter = meter.create_counter("example-counter") .. versionadded:: 1.10.0 +.. versionchanged:: 1.12.0rc """ -from opentelemetry._metrics._internal import ( +from opentelemetry.metrics._internal import ( Meter, MeterProvider, NoOpMeter, @@ -47,7 +48,7 @@ get_meter_provider, set_meter_provider, ) -from opentelemetry._metrics._internal.instrument import ( +from opentelemetry.metrics._internal.instrument import ( Asynchronous, CallbackOptions, CallbackT, @@ -66,7 +67,7 @@ Synchronous, UpDownCounter, ) -from opentelemetry._metrics._internal.observation import Observation +from opentelemetry.metrics._internal.observation import Observation for obj in [ Counter, diff --git a/opentelemetry-api/src/opentelemetry/_metrics/_internal/__init__.py b/opentelemetry-api/src/opentelemetry/metrics/_internal/__init__.py similarity index 95% rename from opentelemetry-api/src/opentelemetry/_metrics/_internal/__init__.py rename to opentelemetry-api/src/opentelemetry/metrics/_internal/__init__.py index b2c67af2268..f3c37b38563 100644 --- a/opentelemetry-api/src/opentelemetry/_metrics/_internal/__init__.py +++ b/opentelemetry-api/src/opentelemetry/metrics/_internal/__init__.py @@ -32,7 +32,7 @@ The following code shows how to obtain a meter using the global :class:`.MeterProvider`:: - from opentelemetry._metrics import get_meter + from opentelemetry.metrics import get_meter meter = get_meter("example-meter") counter = meter.create_counter("example-counter") @@ -47,7 +47,8 @@ from threading import Lock from typing import List, Optional, Sequence, Set, Tuple, Union, cast -from opentelemetry._metrics._internal.instrument import ( +from opentelemetry.environment_variables import OTEL_PYTHON_METER_PROVIDER +from opentelemetry.metrics._internal.instrument import ( CallbackT, Counter, Histogram, @@ -68,9 +69,6 @@ _ProxyObservableUpDownCounter, _ProxyUpDownCounter, ) -from opentelemetry.environment_variables import ( - _OTEL_PYTHON_METER_PROVIDER as OTEL_PYTHON_METER_PROVIDER, -) from opentelemetry.util._once import Once from opentelemetry.util._providers import _load_provider @@ -280,8 +278,8 @@ def create_observable_counter( """Creates an `ObservableCounter` instrument An observable counter observes a monotonically increasing count by calling provided - callbacks which accept a :class:`~opentelemetry._metrics.CallbackOptions` and return - multiple :class:`~opentelemetry._metrics.Observation`. + callbacks which accept a :class:`~opentelemetry.metrics.CallbackOptions` and return + multiple :class:`~opentelemetry.metrics.Observation`. For example, an observable counter could be used to report system CPU time periodically. Here is a basic implementation:: @@ -320,7 +318,7 @@ def cpu_time_callback(options: CallbackOptions) -> Iterable[Observation]: # ... other states Alternatively, you can pass a sequence of generators directly instead of a sequence of - callbacks, which each should return iterables of :class:`~opentelemetry._metrics.Observation`:: + callbacks, which each should return iterables of :class:`~opentelemetry.metrics.Observation`:: def cpu_time_callback(states_to_include: set[str]) -> Iterable[Iterable[Observation]]: # accept options sent in from OpenTelemetry @@ -347,7 +345,7 @@ def cpu_time_callback(states_to_include: set[str]) -> Iterable[Iterable[Observat description="CPU time" ) - The :class:`~opentelemetry._metrics.CallbackOptions` contain a timeout which the + The :class:`~opentelemetry.metrics.CallbackOptions` contain a timeout which the callback should respect. For example if the callback does asynchronous work, like making HTTP requests, it should respect the timeout:: @@ -359,8 +357,8 @@ def scrape_http_callback(options: CallbackOptions) -> Iterable[Observation]: Args: name: The name of the instrument to be created callbacks: A sequence of callbacks that return an iterable of - :class:`~opentelemetry._metrics.Observation`. Alternatively, can be a sequence of generators that each - yields iterables of :class:`~opentelemetry._metrics.Observation`. + :class:`~opentelemetry.metrics.Observation`. Alternatively, can be a sequence of generators that each + yields iterables of :class:`~opentelemetry.metrics.Observation`. unit: The unit for observations this instrument reports. For example, ``By`` for bytes. UCUM units are recommended. description: A description for this instrument and what it measures. @@ -373,7 +371,7 @@ def create_histogram( unit: str = "", description: str = "", ) -> Histogram: - """Creates a :class:`~opentelemetry._metrics.Histogram` instrument + """Creates a :class:`~opentelemetry.metrics.Histogram` instrument Args: name: The name of the instrument to be created @@ -395,8 +393,8 @@ def create_observable_gauge( Args: name: The name of the instrument to be created callbacks: A sequence of callbacks that return an iterable of - :class:`~opentelemetry._metrics.Observation`. Alternatively, can be a generator that yields iterables - of :class:`~opentelemetry._metrics.Observation`. + :class:`~opentelemetry.metrics.Observation`. Alternatively, can be a generator that yields iterables + of :class:`~opentelemetry.metrics.Observation`. unit: The unit for observations this instrument reports. For example, ``By`` for bytes. UCUM units are recommended. description: A description for this instrument and what it measures. @@ -415,8 +413,8 @@ def create_observable_up_down_counter( Args: name: The name of the instrument to be created callbacks: A sequence of callbacks that return an iterable of - :class:`~opentelemetry._metrics.Observation`. Alternatively, can be a generator that yields iterables - of :class:`~opentelemetry._metrics.Observation`. + :class:`~opentelemetry.metrics.Observation`. Alternatively, can be a generator that yields iterables + of :class:`~opentelemetry.metrics.Observation`. unit: The unit for observations this instrument reports. For example, ``By`` for bytes. UCUM units are recommended. description: A description for this instrument and what it measures. @@ -725,7 +723,7 @@ def get_meter( """Returns a `Meter` for use by the given instrumentation library. This function is a convenience wrapper for - `opentelemetry._metrics.MeterProvider.get_meter`. + `opentelemetry.metrics.MeterProvider.get_meter`. If meter_provider is omitted the current configured one is used. """ diff --git a/opentelemetry-api/src/opentelemetry/_metrics/_internal/instrument.py b/opentelemetry-api/src/opentelemetry/metrics/_internal/instrument.py similarity index 98% rename from opentelemetry-api/src/opentelemetry/_metrics/_internal/instrument.py rename to opentelemetry-api/src/opentelemetry/metrics/_internal/instrument.py index 301ba1c3920..f98cbd72430 100644 --- a/opentelemetry-api/src/opentelemetry/_metrics/_internal/instrument.py +++ b/opentelemetry-api/src/opentelemetry/metrics/_internal/instrument.py @@ -33,8 +33,8 @@ ) # pylint: disable=unused-import; needed for typing and sphinx -from opentelemetry import _metrics as metrics -from opentelemetry._metrics._internal.observation import Observation +from opentelemetry import metrics +from opentelemetry.metrics._internal.observation import Observation from opentelemetry.util.types import Attributes _logger = getLogger(__name__) diff --git a/opentelemetry-api/src/opentelemetry/_metrics/_internal/observation.py b/opentelemetry-api/src/opentelemetry/metrics/_internal/observation.py similarity index 100% rename from opentelemetry-api/src/opentelemetry/_metrics/_internal/observation.py rename to opentelemetry-api/src/opentelemetry/metrics/_internal/observation.py diff --git a/opentelemetry-api/src/opentelemetry/util/_providers.py b/opentelemetry-api/src/opentelemetry/util/_providers.py index f19c32ee86d..d8feb88d62d 100644 --- a/opentelemetry-api/src/opentelemetry/util/_providers.py +++ b/opentelemetry-api/src/opentelemetry/util/_providers.py @@ -19,7 +19,7 @@ from pkg_resources import iter_entry_points if TYPE_CHECKING: - from opentelemetry._metrics import MeterProvider + from opentelemetry.metrics import MeterProvider from opentelemetry.trace import TracerProvider Provider = TypeVar("Provider", "TracerProvider", "MeterProvider") diff --git a/opentelemetry-api/tests/metrics/test_instruments.py b/opentelemetry-api/tests/metrics/test_instruments.py index 42967d49019..ff2ab2b3e52 100644 --- a/opentelemetry-api/tests/metrics/test_instruments.py +++ b/opentelemetry-api/tests/metrics/test_instruments.py @@ -16,7 +16,7 @@ from inspect import Signature, isabstract, signature from unittest import TestCase -from opentelemetry._metrics import ( +from opentelemetry.metrics import ( Counter, Histogram, Instrument, diff --git a/opentelemetry-api/tests/metrics/test_meter.py b/opentelemetry-api/tests/metrics/test_meter.py index 3b7f702dfba..44e81bdc8c8 100644 --- a/opentelemetry-api/tests/metrics/test_meter.py +++ b/opentelemetry-api/tests/metrics/test_meter.py @@ -17,7 +17,7 @@ from unittest import TestCase from unittest.mock import Mock -from opentelemetry._metrics import Meter, NoOpMeter +from opentelemetry.metrics import Meter, NoOpMeter # FIXME Test that the meter methods can be called concurrently safely. diff --git a/opentelemetry-api/tests/metrics/test_meter_provider.py b/opentelemetry-api/tests/metrics/test_meter_provider.py index ef49ddaf87d..2fa9fe1e736 100644 --- a/opentelemetry-api/tests/metrics/test_meter_provider.py +++ b/opentelemetry-api/tests/metrics/test_meter_provider.py @@ -18,16 +18,17 @@ from pytest import fixture -import opentelemetry._metrics._internal as metrics_internal -from opentelemetry import _metrics as metrics -from opentelemetry._metrics import ( +import opentelemetry.metrics._internal as metrics_internal +from opentelemetry import metrics +from opentelemetry.environment_variables import OTEL_PYTHON_METER_PROVIDER +from opentelemetry.metrics import ( NoOpMeter, NoOpMeterProvider, get_meter_provider, set_meter_provider, ) -from opentelemetry._metrics._internal import _ProxyMeter, _ProxyMeterProvider -from opentelemetry._metrics._internal.instrument import ( +from opentelemetry.metrics._internal import _ProxyMeter, _ProxyMeterProvider +from opentelemetry.metrics._internal.instrument import ( _ProxyCounter, _ProxyHistogram, _ProxyObservableCounter, @@ -35,9 +36,6 @@ _ProxyObservableUpDownCounter, _ProxyUpDownCounter, ) -from opentelemetry.environment_variables import ( - _OTEL_PYTHON_METER_PROVIDER as OTEL_PYTHON_METER_PROVIDER, -) from opentelemetry.test.globals_test import ( MetricsGlobalsTest, reset_metrics_globals, @@ -72,7 +70,7 @@ def test_set_meter_provider(reset_meter_provider): def test_set_meter_provider_calls_proxy_provider(reset_meter_provider): with patch( - "opentelemetry._metrics._internal._PROXY_METER_PROVIDER" + "opentelemetry.metrics._internal._PROXY_METER_PROVIDER" ) as mock_proxy_mp: assert metrics_internal._PROXY_METER_PROVIDER is mock_proxy_mp mock_real_mp = Mock() @@ -97,9 +95,9 @@ def test_get_meter_provider(reset_meter_provider): "os.environ", {OTEL_PYTHON_METER_PROVIDER: "test_meter_provider"} ): - with patch("opentelemetry._metrics._internal._load_provider", Mock()): + with patch("opentelemetry.metrics._internal._load_provider", Mock()): with patch( - "opentelemetry._metrics._internal.cast", + "opentelemetry.metrics._internal.cast", Mock(**{"return_value": "test_meter_provider"}), ): assert get_meter_provider() == "test_meter_provider" diff --git a/opentelemetry-api/tests/metrics/test_observation.py b/opentelemetry-api/tests/metrics/test_observation.py index 05c644dbd35..0881f043b7b 100644 --- a/opentelemetry-api/tests/metrics/test_observation.py +++ b/opentelemetry-api/tests/metrics/test_observation.py @@ -14,7 +14,7 @@ from unittest import TestCase -from opentelemetry._metrics import Observation +from opentelemetry.metrics import Observation class TestObservation(TestCase): diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/environment_variables.py b/opentelemetry-sdk/src/opentelemetry/sdk/environment_variables.py index 3e632bc521f..145489a683e 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/environment_variables.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/environment_variables.py @@ -407,7 +407,7 @@ LogEmitterProvider is used. """ -_OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE = ( +OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE = ( "OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE" ) """ diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py similarity index 86% rename from opentelemetry-sdk/src/opentelemetry/sdk/_metrics/__init__.py rename to opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py index feecdd21778..d57c3b5896e 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py @@ -14,11 +14,11 @@ # pylint: disable=unused-import -from opentelemetry.sdk._metrics._internal import ( # noqa: F401 +from opentelemetry.sdk.metrics._internal import ( # noqa: F401 Meter, MeterProvider, ) -from opentelemetry.sdk._metrics._internal.instrument import ( # noqa: F401 +from opentelemetry.sdk.metrics._internal.instrument import ( # noqa: F401 Counter, Histogram, ObservableCounter, diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/__init__.py similarity index 92% rename from opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/__init__.py rename to opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/__init__.py index 1d8c908a0a8..c75a175007b 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/__init__.py @@ -18,19 +18,19 @@ from typing import Optional, Sequence # This kind of import is needed to avoid Sphinx errors. -import opentelemetry.sdk._metrics -from opentelemetry._metrics import Counter as APICounter -from opentelemetry._metrics import Histogram as APIHistogram -from opentelemetry._metrics import Meter as APIMeter -from opentelemetry._metrics import MeterProvider as APIMeterProvider -from opentelemetry._metrics import NoOpMeter -from opentelemetry._metrics import ObservableCounter as APIObservableCounter -from opentelemetry._metrics import ObservableGauge as APIObservableGauge -from opentelemetry._metrics import ( +import opentelemetry.sdk.metrics +from opentelemetry.metrics import Counter as APICounter +from opentelemetry.metrics import Histogram as APIHistogram +from opentelemetry.metrics import Meter as APIMeter +from opentelemetry.metrics import MeterProvider as APIMeterProvider +from opentelemetry.metrics import NoOpMeter +from opentelemetry.metrics import ObservableCounter as APIObservableCounter +from opentelemetry.metrics import ObservableGauge as APIObservableGauge +from opentelemetry.metrics import ( ObservableUpDownCounter as APIObservableUpDownCounter, ) -from opentelemetry._metrics import UpDownCounter as APIUpDownCounter -from opentelemetry.sdk._metrics._internal.instrument import ( +from opentelemetry.metrics import UpDownCounter as APIUpDownCounter +from opentelemetry.sdk.metrics._internal.instrument import ( Counter, Histogram, ObservableCounter, @@ -38,11 +38,11 @@ ObservableUpDownCounter, UpDownCounter, ) -from opentelemetry.sdk._metrics._internal.measurement_consumer import ( +from opentelemetry.sdk.metrics._internal.measurement_consumer import ( MeasurementConsumer, SynchronousMeasurementConsumer, ) -from opentelemetry.sdk._metrics._internal.sdk_configuration import ( +from opentelemetry.sdk.metrics._internal.sdk_configuration import ( SdkConfiguration, ) from opentelemetry.sdk.resources import Resource @@ -54,7 +54,7 @@ class Meter(APIMeter): - """See `opentelemetry._metrics.Meter`.""" + """See `opentelemetry.metrics.Meter`.""" def __init__( self, @@ -295,11 +295,11 @@ def create_observable_up_down_counter( class MeterProvider(APIMeterProvider): - r"""See `opentelemetry._metrics.MeterProvider`. + r"""See `opentelemetry.metrics.MeterProvider`. Args: metric_readers: Register metric readers to collect metrics from the SDK - on demand. Each :class:`opentelemetry.sdk._metrics.export.MetricReader` is + on demand. Each :class:`opentelemetry.sdk.metrics.export.MetricReader` is completely independent and will collect separate streams of metrics. TODO: reference ``PeriodicExportingMetricReader`` usage with push exporters here. @@ -308,10 +308,10 @@ class MeterProvider(APIMeterProvider): `MeterProvider.shutdown` views: The views to configure the metric output the SDK - By default, instruments which do not match any :class:`opentelemetry.sdk._metrics.view.View` (or if no :class:`opentelemetry.sdk._metrics.view.View`\ s + By default, instruments which do not match any :class:`opentelemetry.sdk.metrics.view.View` (or if no :class:`opentelemetry.sdk.metrics.view.View`\ s are provided) will report metrics with the default aggregation for the instrument's kind. To disable instruments by default, configure a match-all - :class:`opentelemetry.sdk._metrics.view.View` with `DropAggregation` and then create :class:`opentelemetry.sdk._metrics.view.View`\ s to re-enable + :class:`opentelemetry.sdk.metrics.view.View` with `DropAggregation` and then create :class:`opentelemetry.sdk.metrics.view.View`\ s to re-enable individual instruments: .. code-block:: python @@ -332,11 +332,11 @@ class MeterProvider(APIMeterProvider): def __init__( self, metric_readers: Sequence[ - "opentelemetry.sdk._metrics.export.MetricReader" + "opentelemetry.sdk.metrics.export.MetricReader" ] = (), resource: Resource = Resource.create({}), shutdown_on_exit: bool = True, - views: Sequence["opentelemetry.sdk._metrics.view.View"] = (), + views: Sequence["opentelemetry.sdk.metrics.view.View"] = (), ): self._lock = Lock() self._meter_lock = Lock() diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/_view_instrument_match.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/_view_instrument_match.py similarity index 92% rename from opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/_view_instrument_match.py rename to opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/_view_instrument_match.py index 53ddf0a0ab4..972b39a321f 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/_view_instrument_match.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/_view_instrument_match.py @@ -17,17 +17,17 @@ from threading import Lock from typing import Dict, Iterable -from opentelemetry._metrics import Instrument -from opentelemetry.sdk._metrics._internal.aggregation import ( +from opentelemetry.metrics import Instrument +from opentelemetry.sdk.metrics._internal.aggregation import ( Aggregation, DefaultAggregation, _Aggregation, _SumAggregation, ) -from opentelemetry.sdk._metrics._internal.export import AggregationTemporality -from opentelemetry.sdk._metrics._internal.measurement import Measurement -from opentelemetry.sdk._metrics._internal.point import DataPointT -from opentelemetry.sdk._metrics._internal.view import View +from opentelemetry.sdk.metrics._internal.export import AggregationTemporality +from opentelemetry.sdk.metrics._internal.measurement import Measurement +from opentelemetry.sdk.metrics._internal.point import DataPointT +from opentelemetry.sdk.metrics._internal.view import View from opentelemetry.util._time import _time_ns _logger = getLogger(__name__) diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/aggregation.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/aggregation.py similarity index 96% rename from opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/aggregation.py rename to opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/aggregation.py index c629eb0da26..d7d825c9c5a 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/aggregation.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/aggregation.py @@ -20,7 +20,7 @@ from threading import Lock from typing import Generic, List, Optional, Sequence, TypeVar -from opentelemetry._metrics import ( +from opentelemetry.metrics import ( Asynchronous, Counter, Histogram, @@ -31,12 +31,12 @@ Synchronous, UpDownCounter, ) -from opentelemetry.sdk._metrics._internal.measurement import Measurement -from opentelemetry.sdk._metrics._internal.point import Gauge -from opentelemetry.sdk._metrics._internal.point import ( +from opentelemetry.sdk.metrics._internal.measurement import Measurement +from opentelemetry.sdk.metrics._internal.point import Gauge +from opentelemetry.sdk.metrics._internal.point import ( Histogram as HistogramPoint, ) -from opentelemetry.sdk._metrics._internal.point import ( +from opentelemetry.sdk.metrics._internal.point import ( HistogramDataPoint, NumberDataPoint, Sum, @@ -369,12 +369,12 @@ class DefaultAggregation(Aggregation): ==================================================== ==================================== Instrument Aggregation ==================================================== ==================================== - `opentelemetry.sdk._metrics.Counter` `SumAggregation` - `opentelemetry.sdk._metrics.UpDownCounter` `SumAggregation` - `opentelemetry.sdk._metrics.ObservableCounter` `SumAggregation` - `opentelemetry.sdk._metrics.ObservableUpDownCounter` `SumAggregation` - `opentelemetry.sdk._metrics.Histogram` `ExplicitBucketHistogramAggregation` - `opentelemetry.sdk._metrics.ObservableGauge` `LastValueAggregation` + `opentelemetry.sdk.metrics.Counter` `SumAggregation` + `opentelemetry.sdk.metrics.UpDownCounter` `SumAggregation` + `opentelemetry.sdk.metrics.ObservableCounter` `SumAggregation` + `opentelemetry.sdk.metrics.ObservableUpDownCounter` `SumAggregation` + `opentelemetry.sdk.metrics.Histogram` `ExplicitBucketHistogramAggregation` + `opentelemetry.sdk.metrics.ObservableGauge` `LastValueAggregation` ==================================================== ==================================== """ diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/export/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/__init__.py similarity index 90% rename from opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/export/__init__.py rename to opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/__init__.py index 1b10d2da66c..bcaca4281ee 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/export/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/__init__.py @@ -24,18 +24,21 @@ from typing_extensions import final # This kind of import is needed to avoid Sphinx errors. -import opentelemetry.sdk._metrics._internal +import opentelemetry.sdk.metrics._internal from opentelemetry.context import ( _SUPPRESS_INSTRUMENTATION_KEY, attach, detach, set_value, ) -from opentelemetry.sdk._metrics._internal.aggregation import ( +from opentelemetry.sdk.environment_variables import ( + OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, +) +from opentelemetry.sdk.metrics._internal.aggregation import ( AggregationTemporality, DefaultAggregation, ) -from opentelemetry.sdk._metrics._internal.instrument import ( +from opentelemetry.sdk.metrics._internal.instrument import ( Counter, Histogram, ObservableCounter, @@ -43,10 +46,7 @@ ObservableUpDownCounter, UpDownCounter, ) -from opentelemetry.sdk._metrics._internal.point import MetricsData -from opentelemetry.sdk.environment_variables import ( - _OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, -) +from opentelemetry.sdk.metrics._internal.point import MetricsData from opentelemetry.util._once import Once from opentelemetry.util._time import _time_ns @@ -79,7 +79,7 @@ def export( """Exports a batch of telemetry data. Args: - metrics: The list of `opentelemetry.sdk._metrics.export.Metric` objects to be exported + metrics: The list of `opentelemetry.sdk.metrics.export.Metric` objects to be exported Returns: The result of the export @@ -105,7 +105,7 @@ def __init__( self, out: IO = stdout, formatter: Callable[ - ["opentelemetry.sdk._metrics.export.Metric"], str + ["opentelemetry.sdk.metrics.export.Metric"], str ] = lambda metric: metric.to_json() + linesep, ): @@ -168,20 +168,20 @@ def __init__( self, preferred_temporality: Dict[type, AggregationTemporality] = None, preferred_aggregation: Dict[ - type, "opentelemetry.sdk._metrics.view.Aggregation" + type, "opentelemetry.sdk.metrics.view.Aggregation" ] = None, ) -> None: self._collect: Callable[ [ - "opentelemetry.sdk._metrics.export.MetricReader", + "opentelemetry.sdk.metrics.export.MetricReader", AggregationTemporality, ], - Iterable["opentelemetry.sdk._metrics.export.Metric"], + Iterable["opentelemetry.sdk.metrics.export.Metric"], ] = None if ( environ.get( - _OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, + OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, "CUMULATIVE", ) .upper() @@ -250,10 +250,10 @@ def _set_collect_callback( self, func: Callable[ [ - "opentelemetry.sdk._metrics.export.MetricReader", + "opentelemetry.sdk.metrics.export.MetricReader", AggregationTemporality, ], - Iterable["opentelemetry.sdk._metrics.export.Metric"], + Iterable["opentelemetry.sdk.metrics.export.Metric"], ], ) -> None: """This function is internal to the SDK. It should not be called or overriden by users""" @@ -262,7 +262,7 @@ def _set_collect_callback( @abstractmethod def _receive_metrics( self, - metrics_data: "opentelemetry.sdk._metrics.export.MetricsData", + metrics_data: "opentelemetry.sdk.metrics.export.MetricsData", timeout_millis: float = 10_000, **kwargs, ) -> None: @@ -276,8 +276,8 @@ def shutdown(self, timeout_millis: float = 30_000, **kwargs) -> None: failure status. When a `MetricReader` is registered on a - :class:`~opentelemetry.sdk._metrics.MeterProvider`, - :meth:`~opentelemetry.sdk._metrics.MeterProvider.shutdown` will invoke this + :class:`~opentelemetry.sdk.metrics.MeterProvider`, + :meth:`~opentelemetry.sdk.metrics.MeterProvider.shutdown` will invoke this automatically. """ @@ -292,7 +292,7 @@ def __init__( self, preferred_temporality: Dict[type, AggregationTemporality] = None, preferred_aggregation: Dict[ - type, "opentelemetry.sdk._metrics.view.Aggregation" + type, "opentelemetry.sdk.metrics.view.Aggregation" ] = None, ) -> None: super().__init__( @@ -301,12 +301,12 @@ def __init__( ) self._lock = RLock() self._metrics_data: ( - "opentelemetry.sdk._metrics.export.MetricsData" + "opentelemetry.sdk.metrics.export.MetricsData" ) = None def get_metrics_data( self, - ) -> ("opentelemetry.sdk._metrics.export.MetricsData"): + ) -> ("opentelemetry.sdk.metrics.export.MetricsData"): """Reads and returns current metrics from the SDK""" with self._lock: self.collect() @@ -316,7 +316,7 @@ def get_metrics_data( def _receive_metrics( self, - metrics_data: "opentelemetry.sdk._metrics.export.MetricsData", + metrics_data: "opentelemetry.sdk.metrics.export.MetricsData", timeout_millis: float = 10_000, **kwargs, ) -> None: @@ -338,7 +338,7 @@ def __init__( exporter: MetricExporter, preferred_temporality: Dict[type, AggregationTemporality] = None, preferred_aggregation: Dict[ - type, "opentelemetry.sdk._metrics.view.Aggregation" + type, "opentelemetry.sdk.metrics.view.Aggregation" ] = None, export_interval_millis: Optional[float] = None, export_timeout_millis: Optional[float] = None, diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/instrument.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/instrument.py similarity index 87% rename from opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/instrument.py rename to opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/instrument.py index be0feb7f867..efef08c67f2 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/instrument.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/instrument.py @@ -18,18 +18,18 @@ from typing import Dict, Generator, Iterable, List, Optional, Union # This kind of import is needed to avoid Sphinx errors. -import opentelemetry.sdk._metrics -from opentelemetry._metrics import CallbackT -from opentelemetry._metrics import Counter as APICounter -from opentelemetry._metrics import Histogram as APIHistogram -from opentelemetry._metrics import ObservableCounter as APIObservableCounter -from opentelemetry._metrics import ObservableGauge as APIObservableGauge -from opentelemetry._metrics import ( +import opentelemetry.sdk.metrics +from opentelemetry.metrics import CallbackT +from opentelemetry.metrics import Counter as APICounter +from opentelemetry.metrics import Histogram as APIHistogram +from opentelemetry.metrics import ObservableCounter as APIObservableCounter +from opentelemetry.metrics import ObservableGauge as APIObservableGauge +from opentelemetry.metrics import ( ObservableUpDownCounter as APIObservableUpDownCounter, ) -from opentelemetry._metrics import UpDownCounter as APIUpDownCounter -from opentelemetry._metrics._internal.instrument import CallbackOptions -from opentelemetry.sdk._metrics._internal.measurement import Measurement +from opentelemetry.metrics import UpDownCounter as APIUpDownCounter +from opentelemetry.metrics._internal.instrument import CallbackOptions +from opentelemetry.sdk.metrics._internal.measurement import Measurement from opentelemetry.sdk.util.instrumentation import InstrumentationScope _logger = getLogger(__name__) @@ -45,7 +45,7 @@ def __init__( self, name: str, instrumentation_scope: InstrumentationScope, - measurement_consumer: "opentelemetry.sdk._metrics.MeasurementConsumer", + measurement_consumer: "opentelemetry.sdk.metrics.MeasurementConsumer", unit: str = "", description: str = "", ): @@ -70,7 +70,7 @@ def __init__( self, name: str, instrumentation_scope: InstrumentationScope, - measurement_consumer: "opentelemetry.sdk._metrics.MeasurementConsumer", + measurement_consumer: "opentelemetry.sdk.metrics.MeasurementConsumer", callbacks: Optional[Iterable[CallbackT]] = None, unit: str = "", description: str = "", diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/measurement.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/measurement.py similarity index 95% rename from opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/measurement.py rename to opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/measurement.py index 8a3b8074508..0dced5bcd35 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/measurement.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/measurement.py @@ -15,7 +15,7 @@ from dataclasses import dataclass from typing import Union -from opentelemetry._metrics import Instrument +from opentelemetry.metrics import Instrument from opentelemetry.util.types import Attributes diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/measurement_consumer.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/measurement_consumer.py similarity index 74% rename from opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/measurement_consumer.py rename to opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/measurement_consumer.py index e4d3b56bd80..4ed72bca650 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/measurement_consumer.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/measurement_consumer.py @@ -19,15 +19,15 @@ from typing import Iterable, List, Mapping # This kind of import is needed to avoid Sphinx errors. -import opentelemetry.sdk._metrics -import opentelemetry.sdk._metrics._internal.instrument -import opentelemetry.sdk._metrics._internal.sdk_configuration -from opentelemetry._metrics._internal.instrument import CallbackOptions -from opentelemetry.sdk._metrics._internal.measurement import Measurement -from opentelemetry.sdk._metrics._internal.metric_reader_storage import ( +import opentelemetry.sdk.metrics +import opentelemetry.sdk.metrics._internal.instrument +import opentelemetry.sdk.metrics._internal.sdk_configuration +from opentelemetry.metrics._internal.instrument import CallbackOptions +from opentelemetry.sdk.metrics._internal.measurement import Measurement +from opentelemetry.sdk.metrics._internal.metric_reader_storage import ( MetricReaderStorage, ) -from opentelemetry.sdk._metrics._internal.point import Metric +from opentelemetry.sdk.metrics._internal.point import Metric class MeasurementConsumer(ABC): @@ -39,7 +39,7 @@ def consume_measurement(self, measurement: Measurement) -> None: def register_asynchronous_instrument( self, instrument: ( - "opentelemetry.sdk._metrics._internal.instrument_Asynchronous" + "opentelemetry.sdk.metrics._internal.instrument_Asynchronous" ), ): pass @@ -47,7 +47,7 @@ def register_asynchronous_instrument( @abstractmethod def collect( self, - metric_reader: "opentelemetry.sdk._metrics.MetricReader", + metric_reader: "opentelemetry.sdk.metrics.MetricReader", ) -> Iterable[Metric]: pass @@ -55,13 +55,13 @@ def collect( class SynchronousMeasurementConsumer(MeasurementConsumer): def __init__( self, - sdk_config: "opentelemetry.sdk._metrics._internal.SdkConfiguration", + sdk_config: "opentelemetry.sdk.metrics._internal.SdkConfiguration", ) -> None: self._lock = Lock() self._sdk_config = sdk_config # should never be mutated self._reader_storages: Mapping[ - "opentelemetry.sdk._metrics.MetricReader", MetricReaderStorage + "opentelemetry.sdk.metrics.MetricReader", MetricReaderStorage ] = { reader: MetricReaderStorage( sdk_config, @@ -71,7 +71,7 @@ def __init__( for reader in sdk_config.metric_readers } self._async_instruments: List[ - "opentelemetry.sdk._metrics._internal.instrument._Asynchronous" + "opentelemetry.sdk.metrics._internal.instrument._Asynchronous" ] = [] def consume_measurement(self, measurement: Measurement) -> None: @@ -81,7 +81,7 @@ def consume_measurement(self, measurement: Measurement) -> None: def register_asynchronous_instrument( self, instrument: ( - "opentelemetry.sdk._metrics._internal.instrument._Asynchronous" + "opentelemetry.sdk.metrics._internal.instrument._Asynchronous" ), ) -> None: with self._lock: @@ -89,7 +89,7 @@ def register_asynchronous_instrument( def collect( self, - metric_reader: "opentelemetry.sdk._metrics.MetricReader", + metric_reader: "opentelemetry.sdk.metrics.MetricReader", ) -> Iterable[Metric]: with self._lock: metric_reader_storage = self._reader_storages[metric_reader] diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/metric_reader_storage.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/metric_reader_storage.py similarity index 95% rename from opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/metric_reader_storage.py rename to opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/metric_reader_storage.py index e0397bb729a..702eab4a1e4 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/metric_reader_storage.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/metric_reader_storage.py @@ -16,16 +16,16 @@ from threading import RLock from typing import Dict, List -from opentelemetry._metrics import ( +from opentelemetry.metrics import ( Asynchronous, Counter, Instrument, ObservableCounter, ) -from opentelemetry.sdk._metrics._internal._view_instrument_match import ( +from opentelemetry.sdk.metrics._internal._view_instrument_match import ( _ViewInstrumentMatch, ) -from opentelemetry.sdk._metrics._internal.aggregation import ( +from opentelemetry.sdk.metrics._internal.aggregation import ( Aggregation, ExplicitBucketHistogramAggregation, _DropAggregation, @@ -33,9 +33,9 @@ _LastValueAggregation, _SumAggregation, ) -from opentelemetry.sdk._metrics._internal.export import AggregationTemporality -from opentelemetry.sdk._metrics._internal.measurement import Measurement -from opentelemetry.sdk._metrics._internal.point import ( +from opentelemetry.sdk.metrics._internal.export import AggregationTemporality +from opentelemetry.sdk.metrics._internal.measurement import Measurement +from opentelemetry.sdk.metrics._internal.point import ( Gauge, Histogram, Metric, @@ -44,10 +44,10 @@ ScopeMetrics, Sum, ) -from opentelemetry.sdk._metrics._internal.sdk_configuration import ( +from opentelemetry.sdk.metrics._internal.sdk_configuration import ( SdkConfiguration, ) -from opentelemetry.sdk._metrics._internal.view import View +from opentelemetry.sdk.metrics._internal.view import View from opentelemetry.sdk.util.instrumentation import InstrumentationScope from opentelemetry.util._time import _time_ns diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/point.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/point.py similarity index 96% rename from opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/point.py rename to opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/point.py index 4e57f7a377b..4ae68629678 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/point.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/point.py @@ -19,7 +19,7 @@ from typing import Sequence, Union # This kind of import is needed to avoid Sphinx errors. -import opentelemetry.sdk._metrics._internal +import opentelemetry.sdk.metrics._internal from opentelemetry.sdk.resources import Resource from opentelemetry.sdk.util.instrumentation import InstrumentationScope from opentelemetry.util.types import Attributes @@ -44,7 +44,7 @@ class Sum: data_points: Sequence[NumberDataPoint] aggregation_temporality: ( - "opentelemetry.sdk._metrics.export.AggregationTemporality" + "opentelemetry.sdk.metrics.export.AggregationTemporality" ) is_monotonic: bool @@ -102,7 +102,7 @@ class Histogram: data_points: Sequence[HistogramDataPoint] aggregation_temporality: ( - "opentelemetry.sdk._metrics.export.AggregationTemporality" + "opentelemetry.sdk.metrics.export.AggregationTemporality" ) def to_json(self) -> str: diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/sdk_configuration.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/sdk_configuration.py similarity index 84% rename from opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/sdk_configuration.py rename to opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/sdk_configuration.py index 94d7e110a05..9594ab38a74 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/sdk_configuration.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/sdk_configuration.py @@ -18,12 +18,12 @@ from typing import Sequence # This kind of import is needed to avoid Sphinx errors. -import opentelemetry.sdk._metrics +import opentelemetry.sdk.metrics import opentelemetry.sdk.resources @dataclass class SdkConfiguration: resource: "opentelemetry.sdk.resources.Resource" - metric_readers: Sequence["opentelemetry.sdk._metrics.MetricReader"] - views: Sequence["opentelemetry.sdk._metrics.View"] + metric_readers: Sequence["opentelemetry.sdk.metrics.MetricReader"] + views: Sequence["opentelemetry.sdk.metrics.View"] diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/view.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/view.py similarity index 98% rename from opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/view.py rename to opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/view.py index 4cdca652202..e4f67f0ff21 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_internal/view.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/view.py @@ -20,8 +20,8 @@ # FIXME import from typing when support for 3.6 is removed from typing_extensions import final -from opentelemetry._metrics import Instrument -from opentelemetry.sdk._metrics._internal.aggregation import ( +from opentelemetry.metrics import Instrument +from opentelemetry.sdk.metrics._internal.aggregation import ( Aggregation, DefaultAggregation, ) diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/export/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/__init__.py similarity index 91% rename from opentelemetry-sdk/src/opentelemetry/sdk/_metrics/export/__init__.py rename to opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/__init__.py index 806755997e1..02d3f2aabb3 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/export/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/__init__.py @@ -16,7 +16,7 @@ # FIXME Remove when 3.6 is no longer supported from sys import version_info as _version_info -from opentelemetry.sdk._metrics._internal.export import ( # noqa: F401 +from opentelemetry.sdk.metrics._internal.export import ( # noqa: F401 AggregationTemporality, ConsoleMetricExporter, InMemoryMetricReader, @@ -27,7 +27,7 @@ ) # The point module is not in the export directory to avoid a circular import. -from opentelemetry.sdk._metrics._internal.point import ( # noqa: F401 +from opentelemetry.sdk.metrics._internal.point import ( # noqa: F401 DataPointT, DataT, Gauge, diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/view/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/view/__init__.py similarity index 86% rename from opentelemetry-sdk/src/opentelemetry/sdk/_metrics/view/__init__.py rename to opentelemetry-sdk/src/opentelemetry/sdk/metrics/view/__init__.py index 11218dbb493..b20053d876d 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/view/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/view/__init__.py @@ -14,7 +14,7 @@ # pylint: disable=unused-import -from opentelemetry.sdk._metrics._internal.aggregation import ( # noqa: F401 +from opentelemetry.sdk.metrics._internal.aggregation import ( # noqa: F401 Aggregation, DefaultAggregation, DropAggregation, @@ -22,7 +22,7 @@ LastValueAggregation, SumAggregation, ) -from opentelemetry.sdk._metrics._internal.view import View # noqa: F401 +from opentelemetry.sdk.metrics._internal.view import View # noqa: F401 __all__ = [] for key, value in globals().copy().items(): diff --git a/opentelemetry-sdk/tests/metrics/integration_test/test_cpu_time.py b/opentelemetry-sdk/tests/metrics/integration_test/test_cpu_time.py index b0c07c975c5..7b440c0332a 100644 --- a/opentelemetry-sdk/tests/metrics/integration_test/test_cpu_time.py +++ b/opentelemetry-sdk/tests/metrics/integration_test/test_cpu_time.py @@ -17,9 +17,9 @@ from typing import Generator, Iterable, List from unittest import TestCase -from opentelemetry._metrics import CallbackOptions, Instrument, Observation -from opentelemetry.sdk._metrics import MeterProvider -from opentelemetry.sdk._metrics._internal.measurement import Measurement +from opentelemetry.metrics import CallbackOptions, Instrument, Observation +from opentelemetry.sdk.metrics import MeterProvider +from opentelemetry.sdk.metrics._internal.measurement import Measurement # FIXME Test that the instrument methods can be called concurrently safely. diff --git a/opentelemetry-sdk/tests/metrics/integration_test/test_disable_default_views.py b/opentelemetry-sdk/tests/metrics/integration_test/test_disable_default_views.py index cd8d77ef51e..ad90fe9a298 100644 --- a/opentelemetry-sdk/tests/metrics/integration_test/test_disable_default_views.py +++ b/opentelemetry-sdk/tests/metrics/integration_test/test_disable_default_views.py @@ -14,9 +14,9 @@ from unittest import TestCase -from opentelemetry.sdk._metrics import MeterProvider -from opentelemetry.sdk._metrics.export import InMemoryMetricReader -from opentelemetry.sdk._metrics.view import DropAggregation, View +from opentelemetry.sdk.metrics import MeterProvider +from opentelemetry.sdk.metrics.export import InMemoryMetricReader +from opentelemetry.sdk.metrics.view import DropAggregation, View class TestDisableDefaultViews(TestCase): diff --git a/opentelemetry-sdk/tests/metrics/integration_test/test_time_align.py b/opentelemetry-sdk/tests/metrics/integration_test/test_time_align.py index 64b1899414a..ad34f5622ff 100644 --- a/opentelemetry-sdk/tests/metrics/integration_test/test_time_align.py +++ b/opentelemetry-sdk/tests/metrics/integration_test/test_time_align.py @@ -18,8 +18,8 @@ from pytest import mark -from opentelemetry.sdk._metrics import Counter, MeterProvider -from opentelemetry.sdk._metrics.export import ( +from opentelemetry.sdk.metrics import Counter, MeterProvider +from opentelemetry.sdk.metrics.export import ( AggregationTemporality, InMemoryMetricReader, ) diff --git a/opentelemetry-sdk/tests/metrics/test_aggregation.py b/opentelemetry-sdk/tests/metrics/test_aggregation.py index 21c156f700c..b2245c41365 100644 --- a/opentelemetry-sdk/tests/metrics/test_aggregation.py +++ b/opentelemetry-sdk/tests/metrics/test_aggregation.py @@ -18,7 +18,7 @@ from unittest import TestCase from unittest.mock import Mock -from opentelemetry.sdk._metrics import ( +from opentelemetry.sdk.metrics import ( Counter, Histogram, ObservableCounter, @@ -26,17 +26,17 @@ ObservableUpDownCounter, UpDownCounter, ) -from opentelemetry.sdk._metrics._internal.aggregation import ( +from opentelemetry.sdk.metrics._internal.aggregation import ( _ExplicitBucketHistogramAggregation, _LastValueAggregation, _SumAggregation, ) -from opentelemetry.sdk._metrics._internal.measurement import Measurement -from opentelemetry.sdk._metrics.export import ( +from opentelemetry.sdk.metrics._internal.measurement import Measurement +from opentelemetry.sdk.metrics.export import ( AggregationTemporality, NumberDataPoint, ) -from opentelemetry.sdk._metrics.view import ( +from opentelemetry.sdk.metrics.view import ( DefaultAggregation, ExplicitBucketHistogramAggregation, LastValueAggregation, diff --git a/opentelemetry-sdk/tests/metrics/test_backward_compat.py b/opentelemetry-sdk/tests/metrics/test_backward_compat.py index b59313c1d96..571d7a336ac 100644 --- a/opentelemetry-sdk/tests/metrics/test_backward_compat.py +++ b/opentelemetry-sdk/tests/metrics/test_backward_compat.py @@ -28,10 +28,10 @@ from typing import Iterable, Sequence from unittest import TestCase -from opentelemetry._metrics import CallbackOptions, Observation -from opentelemetry.sdk._metrics import MeterProvider -from opentelemetry.sdk._metrics._internal.export import InMemoryMetricReader -from opentelemetry.sdk._metrics.export import ( +from opentelemetry.metrics import CallbackOptions, Observation +from opentelemetry.sdk.metrics import MeterProvider +from opentelemetry.sdk.metrics._internal.export import InMemoryMetricReader +from opentelemetry.sdk.metrics.export import ( Metric, MetricExporter, MetricExportResult, diff --git a/opentelemetry-sdk/tests/metrics/test_import.py b/opentelemetry-sdk/tests/metrics/test_import.py index 47aa61be1fa..70afa91497f 100644 --- a/opentelemetry-sdk/tests/metrics/test_import.py +++ b/opentelemetry-sdk/tests/metrics/test_import.py @@ -24,7 +24,7 @@ def test_import_init(self): """ try: - from opentelemetry.sdk._metrics import ( # noqa: F401 + from opentelemetry.sdk.metrics import ( # noqa: F401 Counter, Histogram, Meter, @@ -43,7 +43,7 @@ def test_import_export(self): """ try: - from opentelemetry.sdk._metrics.export import ( # noqa: F401 + from opentelemetry.sdk.metrics.export import ( # noqa: F401 AggregationTemporality, ConsoleMetricExporter, DataPointT, @@ -72,7 +72,7 @@ def test_import_view(self): """ try: - from opentelemetry.sdk._metrics.view import ( # noqa: F401 + from opentelemetry.sdk.metrics.view import ( # noqa: F401 Aggregation, DefaultAggregation, DropAggregation, diff --git a/opentelemetry-sdk/tests/metrics/test_in_memory_metric_reader.py b/opentelemetry-sdk/tests/metrics/test_in_memory_metric_reader.py index 99e5b66b510..c32acc7aacd 100644 --- a/opentelemetry-sdk/tests/metrics/test_in_memory_metric_reader.py +++ b/opentelemetry-sdk/tests/metrics/test_in_memory_metric_reader.py @@ -15,9 +15,9 @@ from unittest import TestCase from unittest.mock import Mock -from opentelemetry._metrics import Observation -from opentelemetry.sdk._metrics import MeterProvider -from opentelemetry.sdk._metrics.export import ( +from opentelemetry.metrics import Observation +from opentelemetry.sdk.metrics import MeterProvider +from opentelemetry.sdk.metrics.export import ( AggregationTemporality, InMemoryMetricReader, Metric, diff --git a/opentelemetry-sdk/tests/metrics/test_instrument.py b/opentelemetry-sdk/tests/metrics/test_instrument.py index 909c44ebd40..7a7bef4efce 100644 --- a/opentelemetry-sdk/tests/metrics/test_instrument.py +++ b/opentelemetry-sdk/tests/metrics/test_instrument.py @@ -15,9 +15,9 @@ from unittest import TestCase from unittest.mock import Mock -from opentelemetry._metrics import Observation -from opentelemetry._metrics._internal.instrument import CallbackOptions -from opentelemetry.sdk._metrics import ( +from opentelemetry.metrics import Observation +from opentelemetry.metrics._internal.instrument import CallbackOptions +from opentelemetry.sdk.metrics import ( Counter, Histogram, ObservableCounter, @@ -25,7 +25,7 @@ ObservableUpDownCounter, UpDownCounter, ) -from opentelemetry.sdk._metrics._internal.measurement import Measurement +from opentelemetry.sdk.metrics._internal.measurement import Measurement class TestCounter(TestCase): diff --git a/opentelemetry-sdk/tests/metrics/test_measurement_consumer.py b/opentelemetry-sdk/tests/metrics/test_measurement_consumer.py index f508780b523..3a2a60626b0 100644 --- a/opentelemetry-sdk/tests/metrics/test_measurement_consumer.py +++ b/opentelemetry-sdk/tests/metrics/test_measurement_consumer.py @@ -15,17 +15,17 @@ from unittest import TestCase from unittest.mock import MagicMock, Mock, patch -from opentelemetry.sdk._metrics._internal.measurement_consumer import ( +from opentelemetry.sdk.metrics._internal.measurement_consumer import ( MeasurementConsumer, SynchronousMeasurementConsumer, ) -from opentelemetry.sdk._metrics._internal.sdk_configuration import ( +from opentelemetry.sdk.metrics._internal.sdk_configuration import ( SdkConfiguration, ) @patch( - "opentelemetry.sdk._metrics._internal." + "opentelemetry.sdk.metrics._internal." "measurement_consumer.MetricReaderStorage" ) class TestSynchronousMeasurementConsumer(TestCase): diff --git a/opentelemetry-sdk/tests/metrics/test_metric_reader.py b/opentelemetry-sdk/tests/metrics/test_metric_reader.py index 714dc1cf96b..bc72e8bf986 100644 --- a/opentelemetry-sdk/tests/metrics/test_metric_reader.py +++ b/opentelemetry-sdk/tests/metrics/test_metric_reader.py @@ -17,7 +17,10 @@ from unittest import TestCase from unittest.mock import patch -from opentelemetry.sdk._metrics import ( +from opentelemetry.sdk.environment_variables import ( + OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, +) +from opentelemetry.sdk.metrics import ( Counter, Histogram, ObservableCounter, @@ -25,19 +28,16 @@ ObservableUpDownCounter, UpDownCounter, ) -from opentelemetry.sdk._metrics.export import ( +from opentelemetry.sdk.metrics.export import ( AggregationTemporality, Metric, MetricReader, ) -from opentelemetry.sdk._metrics.view import ( +from opentelemetry.sdk.metrics.view import ( Aggregation, DefaultAggregation, LastValueAggregation, ) -from opentelemetry.sdk.environment_variables import ( - _OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, -) class DummyMetricReader(MetricReader): @@ -66,7 +66,7 @@ def shutdown(self, timeout_millis: float = 30_000, **kwargs) -> None: class TestMetricReader(TestCase): @patch.dict( environ, - {_OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: "CUMULATIVE"}, + {OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: "CUMULATIVE"}, ) def test_configure_temporality_cumulative(self): @@ -91,7 +91,7 @@ def test_configure_temporality_cumulative(self): self.assertEqual(value, AggregationTemporality.CUMULATIVE) @patch.dict( - environ, {_OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: "DELTA"} + environ, {OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: "DELTA"} ) def test_configure_temporality_delta(self): diff --git a/opentelemetry-sdk/tests/metrics/test_metric_reader_storage.py b/opentelemetry-sdk/tests/metrics/test_metric_reader_storage.py index d80a491beb4..1ab0af6ad64 100644 --- a/opentelemetry-sdk/tests/metrics/test_metric_reader_storage.py +++ b/opentelemetry-sdk/tests/metrics/test_metric_reader_storage.py @@ -15,25 +15,25 @@ from logging import WARNING from unittest.mock import MagicMock, Mock, patch -from opentelemetry.sdk._metrics import ( +from opentelemetry.sdk.metrics import ( Counter, Histogram, ObservableCounter, UpDownCounter, ) -from opentelemetry.sdk._metrics._internal.aggregation import ( +from opentelemetry.sdk.metrics._internal.aggregation import ( _LastValueAggregation, ) -from opentelemetry.sdk._metrics._internal.measurement import Measurement -from opentelemetry.sdk._metrics._internal.metric_reader_storage import ( +from opentelemetry.sdk.metrics._internal.measurement import Measurement +from opentelemetry.sdk.metrics._internal.metric_reader_storage import ( _DEFAULT_VIEW, MetricReaderStorage, ) -from opentelemetry.sdk._metrics._internal.sdk_configuration import ( +from opentelemetry.sdk.metrics._internal.sdk_configuration import ( SdkConfiguration, ) -from opentelemetry.sdk._metrics.export import AggregationTemporality -from opentelemetry.sdk._metrics.view import ( +from opentelemetry.sdk.metrics.export import AggregationTemporality +from opentelemetry.sdk.metrics.view import ( DefaultAggregation, DropAggregation, ExplicitBucketHistogramAggregation, @@ -57,7 +57,7 @@ def mock_instrument() -> Mock: class TestMetricReaderStorage(ConcurrencyTestBase): @patch( - "opentelemetry.sdk._metrics._internal" + "opentelemetry.sdk.metrics._internal" ".metric_reader_storage._ViewInstrumentMatch" ) def test_creates_view_instrument_matches( @@ -103,7 +103,7 @@ def test_creates_view_instrument_matches( self.assertEqual(len(MockViewInstrumentMatch.call_args_list), 1) @patch( - "opentelemetry.sdk._metrics._internal." + "opentelemetry.sdk.metrics._internal." "metric_reader_storage._ViewInstrumentMatch" ) def test_forwards_calls_to_view_instrument_match( @@ -222,7 +222,7 @@ def test_forwards_calls_to_view_instrument_match( ) @patch( - "opentelemetry.sdk._metrics._internal." + "opentelemetry.sdk.metrics._internal." "metric_reader_storage._ViewInstrumentMatch" ) def test_race_concurrent_measurements(self, MockViewInstrumentMatch: Mock): @@ -255,7 +255,7 @@ def send_measurement(): self.assertEqual(mock_view_instrument_match_ctor.call_count, 1) @patch( - "opentelemetry.sdk._metrics._internal." + "opentelemetry.sdk.metrics._internal." "metric_reader_storage._ViewInstrumentMatch" ) def test_default_view_enabled(self, MockViewInstrumentMatch: Mock): diff --git a/opentelemetry-sdk/tests/metrics/test_metrics.py b/opentelemetry-sdk/tests/metrics/test_metrics.py index 66efdb833a0..67950c4aaa7 100644 --- a/opentelemetry-sdk/tests/metrics/test_metrics.py +++ b/opentelemetry-sdk/tests/metrics/test_metrics.py @@ -19,8 +19,8 @@ from unittest import TestCase from unittest.mock import MagicMock, Mock, patch -from opentelemetry._metrics import NoOpMeter -from opentelemetry.sdk._metrics import ( +from opentelemetry.metrics import NoOpMeter +from opentelemetry.sdk.metrics import ( Counter, Histogram, Meter, @@ -30,14 +30,14 @@ ObservableUpDownCounter, UpDownCounter, ) -from opentelemetry.sdk._metrics.export import ( +from opentelemetry.sdk.metrics.export import ( Metric, MetricExporter, MetricExportResult, MetricReader, PeriodicExportingMetricReader, ) -from opentelemetry.sdk._metrics.view import SumAggregation, View +from opentelemetry.sdk.metrics.view import SumAggregation, View from opentelemetry.sdk.resources import Resource from opentelemetry.test.concurrency_test import ConcurrencyTestBase, MockFunc @@ -221,7 +221,7 @@ def test_shutdown_subsequent_calls(self): with self.assertLogs(level=WARNING): meter_provider.shutdown() - @patch("opentelemetry.sdk._metrics._internal._logger") + @patch("opentelemetry.sdk.metrics._internal._logger") def test_shutdown_race(self, mock_logger): mock_logger.warning = MockFunc() meter_provider = MeterProvider() @@ -232,8 +232,7 @@ def test_shutdown_race(self, mock_logger): self.assertEqual(mock_logger.warning.call_count, num_threads - 1) @patch( - "opentelemetry.sdk._metrics._internal." - "SynchronousMeasurementConsumer" + "opentelemetry.sdk.metrics._internal." "SynchronousMeasurementConsumer" ) def test_measurement_collect_callback( self, mock_sync_measurement_consumer @@ -256,8 +255,7 @@ def test_measurement_collect_callback( ) @patch( - "opentelemetry.sdk._metrics." - "_internal.SynchronousMeasurementConsumer" + "opentelemetry.sdk.metrics." "_internal.SynchronousMeasurementConsumer" ) def test_creates_sync_measurement_consumer( self, mock_sync_measurement_consumer @@ -266,8 +264,7 @@ def test_creates_sync_measurement_consumer( mock_sync_measurement_consumer.assert_called() @patch( - "opentelemetry.sdk._metrics." - "_internal.SynchronousMeasurementConsumer" + "opentelemetry.sdk.metrics." "_internal.SynchronousMeasurementConsumer" ) def test_register_asynchronous_instrument( self, mock_sync_measurement_consumer @@ -292,8 +289,7 @@ def test_register_asynchronous_instrument( ) @patch( - "opentelemetry.sdk._metrics._internal." - "SynchronousMeasurementConsumer" + "opentelemetry.sdk.metrics._internal." "SynchronousMeasurementConsumer" ) def test_consume_measurement_counter(self, mock_sync_measurement_consumer): sync_consumer_instance = mock_sync_measurement_consumer() @@ -305,8 +301,7 @@ def test_consume_measurement_counter(self, mock_sync_measurement_consumer): sync_consumer_instance.consume_measurement.assert_called() @patch( - "opentelemetry.sdk._metrics." - "_internal.SynchronousMeasurementConsumer" + "opentelemetry.sdk.metrics." "_internal.SynchronousMeasurementConsumer" ) def test_consume_measurement_up_down_counter( self, mock_sync_measurement_consumer @@ -322,8 +317,7 @@ def test_consume_measurement_up_down_counter( sync_consumer_instance.consume_measurement.assert_called() @patch( - "opentelemetry.sdk._metrics._internal." - "SynchronousMeasurementConsumer" + "opentelemetry.sdk.metrics._internal." "SynchronousMeasurementConsumer" ) def test_consume_measurement_histogram( self, mock_sync_measurement_consumer diff --git a/opentelemetry-sdk/tests/metrics/test_periodic_exporting_metric_reader.py b/opentelemetry-sdk/tests/metrics/test_periodic_exporting_metric_reader.py index 597bd37259c..d0f5fc2c451 100644 --- a/opentelemetry-sdk/tests/metrics/test_periodic_exporting_metric_reader.py +++ b/opentelemetry-sdk/tests/metrics/test_periodic_exporting_metric_reader.py @@ -18,7 +18,7 @@ from flaky import flaky -from opentelemetry.sdk._metrics.export import ( +from opentelemetry.sdk.metrics.export import ( Gauge, Metric, MetricExporter, diff --git a/opentelemetry-sdk/tests/metrics/test_point.py b/opentelemetry-sdk/tests/metrics/test_point.py index 7488c85c995..ce3e73b7b0b 100644 --- a/opentelemetry-sdk/tests/metrics/test_point.py +++ b/opentelemetry-sdk/tests/metrics/test_point.py @@ -14,7 +14,7 @@ from unittest import TestCase -from opentelemetry.sdk._metrics.export import ( +from opentelemetry.sdk.metrics.export import ( Gauge, Histogram, HistogramDataPoint, diff --git a/opentelemetry-sdk/tests/metrics/test_view.py b/opentelemetry-sdk/tests/metrics/test_view.py index a78e282244d..2d1fee490f7 100644 --- a/opentelemetry-sdk/tests/metrics/test_view.py +++ b/opentelemetry-sdk/tests/metrics/test_view.py @@ -15,7 +15,7 @@ from unittest import TestCase from unittest.mock import Mock -from opentelemetry.sdk._metrics.view import View +from opentelemetry.sdk.metrics.view import View class TestView(TestCase): diff --git a/opentelemetry-sdk/tests/metrics/test_view_instrument_match.py b/opentelemetry-sdk/tests/metrics/test_view_instrument_match.py index 30312907192..4904f74ddda 100644 --- a/opentelemetry-sdk/tests/metrics/test_view_instrument_match.py +++ b/opentelemetry-sdk/tests/metrics/test_view_instrument_match.py @@ -15,20 +15,20 @@ from unittest import TestCase from unittest.mock import MagicMock, Mock -from opentelemetry.sdk._metrics import Counter -from opentelemetry.sdk._metrics._internal._view_instrument_match import ( +from opentelemetry.sdk.metrics import Counter +from opentelemetry.sdk.metrics._internal._view_instrument_match import ( _ViewInstrumentMatch, ) -from opentelemetry.sdk._metrics._internal.aggregation import ( +from opentelemetry.sdk.metrics._internal.aggregation import ( _DropAggregation, _LastValueAggregation, ) -from opentelemetry.sdk._metrics._internal.measurement import Measurement -from opentelemetry.sdk._metrics._internal.sdk_configuration import ( +from opentelemetry.sdk.metrics._internal.measurement import Measurement +from opentelemetry.sdk.metrics._internal.sdk_configuration import ( SdkConfiguration, ) -from opentelemetry.sdk._metrics.export import AggregationTemporality -from opentelemetry.sdk._metrics.view import ( +from opentelemetry.sdk.metrics.export import AggregationTemporality +from opentelemetry.sdk.metrics.view import ( DefaultAggregation, DropAggregation, LastValueAggregation, diff --git a/opentelemetry-sdk/tests/test_configurator.py b/opentelemetry-sdk/tests/test_configurator.py index 42d3859f5e2..1905e6fc384 100644 --- a/opentelemetry-sdk/tests/test_configurator.py +++ b/opentelemetry-sdk/tests/test_configurator.py @@ -32,7 +32,7 @@ ) from opentelemetry.sdk._logs import LoggingHandler from opentelemetry.sdk._logs.export import ConsoleLogExporter -from opentelemetry.sdk._metrics.export import ConsoleMetricExporter +from opentelemetry.sdk.metrics.export import ConsoleMetricExporter from opentelemetry.sdk.resources import SERVICE_NAME, Resource from opentelemetry.sdk.trace.export import ConsoleSpanExporter from opentelemetry.sdk.trace.id_generator import IdGenerator, RandomIdGenerator diff --git a/tests/opentelemetry-test-utils/src/opentelemetry/test/globals_test.py b/tests/opentelemetry-test-utils/src/opentelemetry/test/globals_test.py index e3d2ba731d2..19ee5f85eaf 100644 --- a/tests/opentelemetry-test-utils/src/opentelemetry/test/globals_test.py +++ b/tests/opentelemetry-test-utils/src/opentelemetry/test/globals_test.py @@ -15,8 +15,8 @@ import unittest from opentelemetry import trace as trace_api -from opentelemetry._metrics import _internal as metrics_api -from opentelemetry._metrics._internal import _ProxyMeterProvider +from opentelemetry.metrics import _internal as metrics_api +from opentelemetry.metrics._internal import _ProxyMeterProvider from opentelemetry.util._once import Once diff --git a/tests/opentelemetry-test-utils/src/opentelemetry/test/metrictestutil.py b/tests/opentelemetry-test-utils/src/opentelemetry/test/metrictestutil.py index d89b4480a0b..59b3a45d20a 100644 --- a/tests/opentelemetry-test-utils/src/opentelemetry/test/metrictestutil.py +++ b/tests/opentelemetry-test-utils/src/opentelemetry/test/metrictestutil.py @@ -14,7 +14,7 @@ from opentelemetry.attributes import BoundedAttributes -from opentelemetry.sdk._metrics.export import ( +from opentelemetry.sdk.metrics.export import ( AggregationTemporality, Gauge, Metric,