A helper class for computing metric differences.
- See also
- ClientMonitor.metrics_diff
Example with await monitor_client.metrics_diff():
async def test_diff_metrics(service_client, monitor_client: pytest_userver.client.ClientMonitor):
async with monitor_client.metrics_diff(prefix='sample-metrics') as differ:
response = await service_client.get('/metrics')
assert response.status == 200
assert differ.value_at('foo') == 1
Definition at line 552 of file client.py.
|
| pytest_userver.metrics.MetricsSnapshot | baseline (self) |
| |
| None | baseline (self, pytest_userver.metrics.MetricsSnapshot value) |
| |
| pytest_userver.metrics.MetricsSnapshot | current (self) |
| |
| None | current (self, pytest_userver.metrics.MetricsSnapshot value) |
| |
| pytest_userver.metrics.MetricsSnapshot | diff (self) |
| |
| pytest_userver.metrics.MetricValue | value_at (self, str|None subpath=None, dict[str, str]|None add_labels=None, *, float|None default=None) |
| | Returns a single metric value at the specified path, prepending the path provided at construction.
|
| |
| pytest_userver.metrics.MetricsSnapshot | fetch (self) |
| | Fetches metric values from the service.
|
| |
| MetricsDiffer | __aenter__ (self) |
| |
| None | __aexit__ (self, exc_type, exc, exc_tb) |
| |
| pytest_userver.metrics.MetricValue pytest_userver.client.MetricsDiffer.value_at |
( |
| self, |
|
|
str | None | subpath = None, |
|
|
dict[str, str] | None | add_labels = None, |
|
|
* | , |
|
|
float | None | default = None ) |
Returns a single metric value at the specified path, prepending the path provided at construction.
If a dict of labels is provided, does en exact match of labels, prepending the labels provided at construction.
- Parameters
-
| subpath | Suffix of the metric path; the path provided at construction is prepended |
| add_labels | Labels that the metric must have in addition to the labels provided at construction |
| default | An optional default value in case the metric is missing |
- Exceptions
-
| AssertionError | if not one metric by path |
Definition at line 619 of file client.py.