8000 Support two or three element tuples in HistogramMetricFamily · prometheus/client_python@b3a00ea · GitHub
[go: up one dir, main page]

Skip to content

Commit b3a00ea

Browse files
committed
Support two or three element tuples in HistogramMetricFamily
Signed-off-by: Chris Marchbanks <csmarchbanks@gmail.com>
1 parent 4b902bf commit b3a00ea

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

prometheus_client/metrics_core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class HistogramMetricFamily(Metric):
232232
def __init__(self,
233233
name: str,
234234
documentation: str,
235-
buckets: Optional[Sequence[Tuple[str, float, Optional[Exemplar]]]] = None,
235+
buckets: Optional[Sequence[Union[Tuple[str, float], Tuple[str, float, Exemplar]]]] = None,
236236
sum_value: Optional[Union[int, float]] = None,
237237
labels: Optional[Sequence[str]] = None,
238238
unit: str = '',
@@ -250,7 +250,7 @@ def __init__(self,
250250

251251
def add_metric(self,
252252
labels: Sequence[str],
253-
buckets: Sequence[Tuple[str, float, Optional[Exemplar]]],
253+
buckets: Sequence[Union[Tuple[str, float], Tuple[str, float, Exemplar]]],
254254
sum_value: Optional[Union[int, float]],
255255
timestamp: Optional[Union[Timestamp, float]] = None) -> None:
256256
"""Add a metric to the metric family.
@@ -267,7 +267,7 @@ def add_metric(self,
267267
bucket, value = b[:2]
268268
exemplar = None
269269
if len(b) == 3:
270-
exemplar = b[2]
270+
exemplar = b[2] # type: ignore
271271
self.samples.append(Sample(
272272
self.name + '_bucket',
273273
dict(list(zip(self._labelnames, labels)) + [('le', bucket)]),

0 commit comments

Comments
 (0)
0