Snapshot of captured metrics that mimics the dict interface. More...
Public Member Functions | |
__init__ (self, typing.Mapping[str, typing.Set[Metric]] values) | |
typing.Set[Metric] | __getitem__ (self, str path) |
Returns a list of metrics by specified path. | |
int | __len__ (self) |
Returns count of metrics paths. | |
__iter__ (self) | |
Returns a (path, list) iterable over the metrics. | |
bool | __contains__ (self, str path) |
Returns True if metric with specified path is in the snapshot, False otherwise. | |
bool | __eq__ (self, object other) |
Compares the snapshot with a dict of metrics or with another snapshot. | |
str | __repr__ (self) |
get (self, str path, default=None) | |
Returns an list of metrics by path or default if there's no such path. | |
items (self) | |
Returns a (path, list) iterable over the metrics. | |
keys (self) | |
Returns an iterable over paths of metrics. | |
values (self) | |
Returns an iterable over lists of metrics. | |
float | value_at (self, str path, typing.Optional[typing.Dict] labels=None, *typing.Optional[float] default=None) |
Returns a single metric value at specified path. | |
None | assert_equals (self, typing.Mapping[str, typing.Set[Metric]] other, *bool ignore_zeros=False) |
Compares the snapshot with a dict of metrics or with another snapshot, displaying a nice diff on mismatch. | |
str | to_json (self) |
Serialize to a JSON string. | |
Static Public Member Functions | |
'MetricsSnapshot' | from_json (str json_str) |
Construct MetricsSnapshot from a JSON string. | |
Protected Attributes | |
_values | |
Snapshot of captured metrics that mimics the dict interface.
Metrics have the 'Dict[str(path), Set[Metric]]' format.
Definition at line 46 of file metrics.py.
pytest_userver.metrics.MetricsSnapshot.__init__ | ( | self, | |
typing.Mapping[str, typing.Set[Metric]] | values | ||
) |
Definition at line 56 of file metrics.py.
bool pytest_userver.metrics.MetricsSnapshot.__contains__ | ( | self, | |
str | path | ||
) |
Returns True if metric with specified path is in the snapshot, False otherwise.
Definition at line 71 of file metrics.py.
bool pytest_userver.metrics.MetricsSnapshot.__eq__ | ( | self, | |
object | other | ||
) |
Compares the snapshot with a dict of metrics or with another snapshot.
Definition at line 78 of file metrics.py.
typing.Set[Metric] pytest_userver.metrics.MetricsSnapshot.__getitem__ | ( | self, | |
str | path | ||
) |
Returns a list of metrics by specified path.
Definition at line 59 of file metrics.py.
pytest_userver.metrics.MetricsSnapshot.__iter__ | ( | self | ) |
Returns a (path, list) iterable over the metrics.
Definition at line 67 of file metrics.py.
int pytest_userver.metrics.MetricsSnapshot.__len__ | ( | self | ) |
Returns count of metrics paths.
Definition at line 63 of file metrics.py.
str pytest_userver.metrics.MetricsSnapshot.__repr__ | ( | self | ) |
Definition at line 85 of file metrics.py.
None pytest_userver.metrics.MetricsSnapshot.assert_equals | ( | self, | |
typing.Mapping[str, typing.Set[Metric]] | other, | ||
*bool | ignore_zeros = False |
||
) |
Compares the snapshot with a dict of metrics or with another snapshot, displaying a nice diff on mismatch.
Definition at line 146 of file metrics.py.
|
static |
Construct MetricsSnapshot from a JSON string.
Definition at line 161 of file metrics.py.
pytest_userver.metrics.MetricsSnapshot.get | ( | self, | |
str | path, | ||
default = None |
|||
) |
Returns an list of metrics by path or default if there's no such path.
Definition at line 88 of file metrics.py.
pytest_userver.metrics.MetricsSnapshot.items | ( | self | ) |
Returns a (path, list) iterable over the metrics.
Definition at line 95 of file metrics.py.
pytest_userver.metrics.MetricsSnapshot.keys | ( | self | ) |
Returns an iterable over paths of metrics.
Definition at line 99 of file metrics.py.
str pytest_userver.metrics.MetricsSnapshot.to_json | ( | self | ) |
Serialize to a JSON string.
Definition at line 174 of file metrics.py.
float pytest_userver.metrics.MetricsSnapshot.value_at | ( | self, | |
str | path, | ||
typing.Optional[typing.Dict] | labels = None , |
||
*typing.Optional[float] | default = None |
||
) |
Returns a single metric value at specified path.
If a dict of labels is provided, does en exact match of labels (i.e. {} stands for no labels; {'a': 'b', 'c': 'd'} matches only {'a': 'b', 'c': 'd'} or {'c': 'd', 'a': 'b'} but neither match {'a': 'b'} nor {'a': 'b', 'c': 'd', 'e': 'f'}).
AssertionError | if not one metric by path |
Definition at line 107 of file metrics.py.
pytest_userver.metrics.MetricsSnapshot.values | ( | self | ) |
Returns an iterable over lists of metrics.
Definition at line 103 of file metrics.py.
|
protected |
Definition at line 57 of file metrics.py.