From 679297f5ebd37510b6c9e086fc27837935d57e81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Em=C3=ADdio=20Neto?= <9735060+emdneto@users.noreply.github.com> Date: Thu, 17 Oct 2024 10:06:53 -0300 Subject: [PATCH] Drop `OTEL_PYTHON_EXPERIMENTAL_DISABLE_PROMETHEUS_UNIT_NORMALIZATION` environment variable (#4217) * remove OTEL_PYTHON_EXPERIMENTAL_DISABLE_PROMETHEUS_UNIT_NORMALIZATION from exporter-prometheus Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com> * ci --------- Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com> --- CHANGELOG.md | 2 ++ .../exporter/prometheus/__init__.py | 14 +---------- .../tests/test_prometheus_exporter.py | 23 ------------------- .../sdk/environment_variables/__init__.py | 18 --------------- 4 files changed, 3 insertions(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33438d21ed..bbe2ca994b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#4222](https://github.com/open-telemetry/opentelemetry-python/pull/4222)) - Record logger name as the instrumentation scope name ([#4208](https://github.com/open-telemetry/opentelemetry-python/pull/4208)) +- Drop `OTEL_PYTHON_EXPERIMENTAL_DISABLE_PROMETHEUS_UNIT_NORMALIZATION` environment variable + ([#4217](https://github.com/open-telemetry/opentelemetry-python/pull/4217)) ## Version 1.27.0/0.48b0 (2024-08-28) 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 801d70c7b6..e0f7360e35 100644 --- a/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/__init__.py +++ b/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/__init__.py @@ -87,7 +87,6 @@ from opentelemetry.sdk.environment_variables import ( OTEL_EXPORTER_PROMETHEUS_HOST, OTEL_EXPORTER_PROMETHEUS_PORT, - OTEL_PYTHON_EXPERIMENTAL_DISABLE_PROMETHEUS_UNIT_NORMALIZATION, ) from opentelemetry.sdk.metrics import ( Counter, @@ -234,18 +233,7 @@ def _translate_to_prometheus( metric_description = metric.description or "" - # TODO(#3929): remove this opt-out option - disable_unit_normalization = ( - environ.get( - OTEL_PYTHON_EXPERIMENTAL_DISABLE_PROMETHEUS_UNIT_NORMALIZATION, - "false", - ).lower() - == "true" - ) - if disable_unit_normalization: - metric_unit = metric.unit - else: - metric_unit = map_unit(metric.unit) + metric_unit = map_unit(metric.unit) for number_data_point in metric.data.data_points: label_keys = [] diff --git a/exporter/opentelemetry-exporter-prometheus/tests/test_prometheus_exporter.py b/exporter/opentelemetry-exporter-prometheus/tests/test_prometheus_exporter.py index 52a1896371..623a16927b 100644 --- a/exporter/opentelemetry-exporter-prometheus/tests/test_prometheus_exporter.py +++ b/exporter/opentelemetry-exporter-prometheus/tests/test_prometheus_exporter.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from os import environ from textwrap import dedent from unittest import TestCase from unittest.mock import Mock, patch @@ -28,9 +27,6 @@ PrometheusMetricReader, _CustomCollector, ) -from opentelemetry.sdk.environment_variables import ( - OTEL_PYTHON_EXPERIMENTAL_DISABLE_PROMETHEUS_UNIT_NORMALIZATION, -) from opentelemetry.sdk.metrics import MeterProvider from opentelemetry.sdk.metrics.export import ( AggregationTemporality, @@ -549,25 +545,6 @@ def test_metric_name_with_unit(self): ), ) - # TODO(#3929): remove this opt-out option - @patch.dict( - environ, - { - OTEL_PYTHON_EXPERIMENTAL_DISABLE_PROMETHEUS_UNIT_NORMALIZATION: "true" - }, - ) - def test_metric_name_with_unit_normalization_disabled(self): - self.verify_text_format( - _generate_sum(name="test_unit_not_normalized", value=1, unit="s"), - dedent( - """\ - # HELP test_unit_not_normalized_s_total foo - # TYPE test_unit_not_normalized_s_total counter - test_unit_not_normalized_s_total{a="1",b="true"} 1.0 - """ - ), - ) - def test_semconv(self): """Tests that a few select semconv metrics get converted to the expected prometheus text format""" diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/environment_variables/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/environment_variables/__init__.py index 5fd4cd94ee..260df81f70 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/environment_variables/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/environment_variables/__init__.py @@ -780,21 +780,3 @@ This is an experimental environment variable and the name of this variable and its behavior can change in a non-backwards compatible way. """ - - -# TODO(#3929): remove this opt-out option -OTEL_PYTHON_EXPERIMENTAL_DISABLE_PROMETHEUS_UNIT_NORMALIZATION = ( - "OTEL_PYTHON_EXPERIMENTAL_DISABLE_PROMETHEUS_UNIT_NORMALIZATION" -) -""" -.. envvar:: OTEL_PYTHON_EXPERIMENTAL_DISABLE_PROMETHEUS_UNIT_NORMALIZATION - -The :envvar:`OTEL_PYTHON_EXPERIMENTAL_DISABLE_PROMETHEUS_UNIT_NORMALIZATION` environment -variable allows you to opt-out of the unit normalization described `in the specification -`_. - -Default: False - -This is an temporary environment variable that provides backward compatibility but will be -removed in the future https://github.com/open-telemetry/opentelemetry-python/issues/3929. -"""