Skip to content

Commit 40528a2

Browse files
committed
fix(sphinx): remove typing for sphinx runthrough
1 parent 86a1690 commit 40528a2

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

ext/opentelemetry-ext-prometheus/src/opentelemetry/ext/prometheus/__init__.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,20 @@
6969
import re
7070
from typing import Iterable, Optional, Sequence, Union
7171

72+
from prometheus_client.core import (
73+
REGISTRY,
74+
CounterMetricFamily,
75+
SummaryMetricFamily,
76+
UnknownMetricFamily,
77+
)
78+
7279
from opentelemetry.metrics import Counter, ValueRecorder
7380
from opentelemetry.sdk.metrics.export import (
7481
MetricRecord,
7582
MetricsExporter,
7683
MetricsExportResult,
7784
)
7885
from opentelemetry.sdk.metrics.export.aggregate import MinMaxSumCountAggregator
79-
from prometheus_client.core import (
80-
REGISTRY,
81-
CounterMetricFamily,
82-
SummaryMetricFamily,
83-
UnknownMetricFamily,
84-
)
8586

8687
logger = logging.getLogger(__name__)
8788

@@ -123,11 +124,7 @@ def __init__(self, prefix: str = ""):
123124
def add_metrics_data(self, metric_records: Sequence[MetricRecord]) -> None:
124125
self._metrics_to_export.append(metric_records)
125126

126-
def collect(
127-
self,
128-
) -> Iterable[
129-
Union[CounterMetricFamily, SummaryMetricFamily, UnknownMetricFamily]
130-
]:
127+
def collect(self):
131128
"""Collect fetches the metrics from OpenTelemetry
132129
and delivers them as Prometheus Metrics.
133130
Collect is invoked every time a prometheus.Gatherer is run
@@ -142,11 +139,7 @@ def collect(
142139
if prometheus_metric is not None:
143140
yield prometheus_metric
144141

145-
def _translate_to_prometheus(
146-
self, metric_record: MetricRecord
147-
) -> Optional[
148-
Union[CounterMetricFamily, SummaryMetricFamily, UnknownMetricFamily]
149-
]:
142+
def _translate_to_prometheus(self, metric_record: MetricRecord):
150143
prometheus_metric = None
151144
label_values = []
152145
label_keys = []
@@ -170,7 +163,9 @@ def _translate_to_prometheus(
170163
# TODO: Add support for histograms when supported in OT
171164
elif isinstance(metric_record.instrument, ValueRecorder):
172165
value = metric_record.aggregator.checkpoint
173-
if isinstance(value, MinMaxSumCountAggregator._TYPE):
166+
if isinstance(
167+
value, MinMaxSumCountAggregator._TYPE # pylint: disable=W0212
168+
):
174169
value = metric_record.aggregator.checkpoint
175170
prometheus_metric = SummaryMetricFamily(
176171
name=metric_name,

ext/opentelemetry-ext-prometheus/tests/test_prometheus_exporter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from unittest import mock
1717

1818
from prometheus_client import generate_latest
19-
from prometheus_client.core import CounterMetricFamily, SummaryMetricFamily
19+
from prometheus_client.core import CounterMetricFamily
2020

2121
from opentelemetry.ext.prometheus import (
2222
CustomCollector,
@@ -26,8 +26,8 @@
2626
from opentelemetry.sdk import metrics
2727
from opentelemetry.sdk.metrics.export import MetricRecord, MetricsExportResult
2828
from opentelemetry.sdk.metrics.export.aggregate import (
29-
SumAggregator,
3029
MinMaxSumCountAggregator,
30+
SumAggregator,
3131
)
3232

3333

0 commit comments

Comments
 (0)