Skip to content

Commit 17de6c9

Browse files
committed
Revert "Select histogram aggregation with environment variables"
This reverts commit fa1a167.
1 parent fa1a167 commit 17de6c9

File tree

4 files changed

+2
-95
lines changed

4 files changed

+2
-95
lines changed

CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10-
- Enable selection of histogram aggregation via environment variable
11-
([#3265](https://github.com/open-telemetry/opentelemetry-python/pull/3265))
1210
- Move Protobuf encoding to its own package
1311
([#3169](https://github.com/open-telemetry/opentelemetry-python/pull/3169))
1412
- Add experimental feature to detect resource detectors in auto instrumentation

opentelemetry-sdk/src/opentelemetry/sdk/environment_variables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@
650650
The :envvar:`OTEL_METRICS_EXEMPLAR_FILTER` is the filter for which measurements can become Exemplars.
651651
"""
652652

653-
OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION = (
653+
_OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION = (
654654
"OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION"
655655
)
656656
"""

opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/aggregation.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from enum import IntEnum
2020
from logging import getLogger
2121
from math import inf
22-
from os import environ
2322
from threading import Lock
2423
from typing import Generic, List, Optional, Sequence, TypeVar
2524

@@ -34,9 +33,6 @@
3433
Synchronous,
3534
UpDownCounter,
3635
)
37-
from opentelemetry.sdk.environment_variables import (
38-
OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION,
39-
)
4036
from opentelemetry.sdk.metrics._internal.exponential_histogram.buckets import (
4137
Buckets,
4238
)
@@ -931,29 +927,6 @@ def _create_aggregation(
931927
)
932928

933929
if isinstance(instrument, Histogram):
934-
935-
histogram_type = environ.get(
936-
OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION,
937-
"explicit_bucket_histogram",
938-
)
939-
940-
if histogram_type == "base2_exponential_bucket_histogram":
941-
942-
return _ExponentialBucketHistogramAggregation(
943-
attributes, start_time_unix_nano
944-
)
945-
946-
if histogram_type != "explicit_bucket_histogram":
947-
948-
_logger.warning(
949-
(
950-
"Invalid value for %s: %s, using explicit bucket "
951-
"histogram aggregation"
952-
),
953-
OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION,
954-
histogram_type,
955-
)
956-
957930
return _ExplicitBucketHistogramAggregation(
958931
attributes, start_time_unix_nano
959932
)

opentelemetry-sdk/tests/metrics/test_aggregation.py

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,14 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from logging import WARNING
1615
from math import inf
17-
from os import environ
1816
from time import sleep
1917
from typing import Union
2018
from unittest import TestCase
21-
from unittest.mock import Mock, patch
19+
from unittest.mock import Mock
2220

23-
from opentelemetry.metrics import Histogram
24-
from opentelemetry.sdk.environment_variables import (
25-
OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION,
26-
)
2721
from opentelemetry.sdk.metrics._internal.aggregation import (
2822
_ExplicitBucketHistogramAggregation,
29-
_ExponentialBucketHistogramAggregation,
3023
_LastValueAggregation,
3124
_SumAggregation,
3225
)
@@ -548,60 +541,3 @@ def test_observable_gauge(self):
548541
0,
549542
)
550543
self.assertIsInstance(aggregation, _LastValueAggregation)
551-
552-
def test_exponential_explicit_bucket_histogram(self):
553-
554-
histogram = Mock(spec=Histogram)
555-
default_aggregation = DefaultAggregation()
556-
557-
self.assertIsInstance(
558-
default_aggregation._create_aggregation(histogram, Mock(), Mock()),
559-
_ExplicitBucketHistogramAggregation,
560-
)
561-
562-
with patch.dict(
563-
environ,
564-
{
565-
OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION: "base2_exponential_bucket_histogram"
566-
},
567-
):
568-
self.assertIsInstance(
569-
default_aggregation._create_aggregation(
570-
histogram, Mock(), Mock()
571-
),
572-
_ExponentialBucketHistogramAggregation,
573-
)
574-
575-
with patch.dict(
576-
environ,
577-
{OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION: "abc"},
578-
):
579-
with self.assertLogs(level=WARNING) as log:
580-
self.assertIsInstance(
581-
default_aggregation._create_aggregation(
582-
histogram, Mock(), Mock()
583-
),
584-
_ExplicitBucketHistogramAggregation,
585-
)
586-
self.assertEqual(
587-
log.output[0],
588-
(
589-
"WARNING:opentelemetry.sdk.metrics._internal.aggregation:"
590-
"Invalid value for OTEL_EXPORTER_OTLP_METRICS_DEFAULT_"
591-
"HISTOGRAM_AGGREGATION: abc, using explicit bucket "
592-
"histogram aggregation"
593-
),
594-
)
595-
596-
with patch.dict(
597-
environ,
598-
{
599-
OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION: "explicit_bucket_histogram"
600-
},
601-
):
602-
self.assertIsInstance(
603-
default_aggregation._create_aggregation(
604-
histogram, Mock(), Mock()
605-
),
606-
_ExplicitBucketHistogramAggregation,
607-
)

0 commit comments

Comments
 (0)