Skip to content

Commit

Permalink
make Sample namedtuple use Dict instead of Mapping
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Kulinski <d@kulinski.us>
  • Loading branch information
takeda committed Nov 30, 2021
1 parent 098b758 commit 9f406df
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 1 addition & 2 deletions prometheus_client/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ def _multi_samples(self):
for suffix, sample_labels, value, timestamp, exemplar in metric._samples():
yield (suffix, dict(series_labels + list(sample_labels.items())), value, timestamp, exemplar)

def _child_samples(self): # pragma: no cover
# type: () -> Sequence[Tuple[str, Dict[str, str], float]]
def _child_samples(self) -> Sequence[Tuple[str, Dict[str, str], float]]: # pragma: no cover
raise NotImplementedError('_child_samples() must be implemented by %r' % self)

def _metric_init(self): # pragma: no cover
Expand Down
7 changes: 3 additions & 4 deletions prometheus_client/samples.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from collections import namedtuple
from typing import Mapping, NamedTuple, Optional, Sequence
from typing import Dict, NamedTuple, Optional


class Timestamp:
Expand Down Expand Up @@ -38,14 +37,14 @@ def __gt__(self, other):
# a Timestamp object, or None.
# Exemplar can be an Exemplar object, or None.
class Exemplar(NamedTuple):
labels: Mapping[str, str]
labels: Dict[str, str]
value: float
timestamp: Optional[float] = None


class Sample(NamedTuple):
name: str
labels: Mapping[str, str]
labels: Dict[str, str]
value: float
timestamp: Optional[float] = None
exemplar: Optional[Exemplar] = None

0 comments on commit 9f406df

Please sign in to comment.