Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make metrics public #2684

Merged
merged 11 commits into from
May 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 3 additions & 10 deletions docs/api/metrics.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
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::


Module contents
---------------

.. automodule:: opentelemetry._metrics
.. automodule:: opentelemetry.metrics
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down
7 changes: 1 addition & 6 deletions docs/examples/metrics/README.rst
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -45,4 +40,4 @@ The resulting metrics will appear in the output from the collector and look simi

.. code-block:: sh

TODO
TODO
ocelotl marked this conversation as resolved.
Show resolved Hide resolved
14 changes: 7 additions & 7 deletions docs/examples/metrics/example.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 3 additions & 3 deletions docs/getting_started/metrics_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
6 changes: 3 additions & 3 deletions docs/sdk/metrics.export.rst
Original file line number Diff line number Diff line change
@@ -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:
11 changes: 2 additions & 9 deletions docs/sdk/metrics.rst
Original file line number Diff line number Diff line change
@@ -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
----------

Expand All @@ -16,7 +9,7 @@ Submodules
metrics.export
metrics.view

.. automodule:: opentelemetry.sdk._metrics
.. automodule:: opentelemetry.sdk.metrics
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/sdk/metrics.view.rst
Original file line number Diff line number Diff line change
@@ -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:
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion exporter/opentelemetry-exporter-otlp/tests/test_otlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
PrometheusMetricReader,
_CustomCollector,
)
from opentelemetry.sdk._metrics.export import (
from opentelemetry.sdk.metrics.export import (
AggregationTemporality,
Histogram,
HistogramDataPoint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Original file line number Diff line number Diff line change
Expand Up @@ -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
ocelotl marked this conversation as resolved.
Show resolved Hide resolved
.. versionchanged:: 1.12.0rc
"""

from opentelemetry._metrics._internal import (
from opentelemetry.metrics._internal import (
Meter,
MeterProvider,
NoOpMeter,
Expand All @@ -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,
Expand All @@ -66,7 +67,7 @@
Synchronous,
UpDownCounter,
)
from opentelemetry._metrics._internal.observation import Observation
from opentelemetry.metrics._internal.observation import Observation

for obj in [
Counter,
Expand Down
Loading