Skip to content

Drop OTEL_PYTHON_EXPERIMENTAL_DISABLE_PROMETHEUS_UNIT_NORMALIZATION environment variable #4217

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

Merged
merged 4 commits into from
Oct 17, 2024
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 @@ -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.
"""