Skip to content

Commit

Permalink
Drop OTEL_PYTHON_EXPERIMENTAL_DISABLE_PROMETHEUS_UNIT_NORMALIZATION
Browse files Browse the repository at this point in the history
… environment variable (#4217)

* remove OTEL_PYTHON_EXPERIMENTAL_DISABLE_PROMETHEUS_UNIT_NORMALIZATION from exporter-prometheus

Signed-off-by: emdneto <[email protected]>

* ci

---------

Signed-off-by: emdneto <[email protected]>
  • Loading branch information
emdneto authored Oct 17, 2024
1 parent affecbd commit 679297f
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 54 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
<https://github.com/open-telemetry/opentelemetry-specification/blob/v1.33.0/specification/compatibility/prometheus_and_openmetrics.md#metric-metadata-1>`_.
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.
"""

0 comments on commit 679297f

Please sign in to comment.