Asyncio userver client for monitor listeners, typically retrieved from plugins.service_client.monitor_client fixture.
Compatible with werkzeug interface.
Inheritance diagram for pytest_userver.client.ClientMonitor:Public Member Functions | |
| MetricsDiffer | metrics_diff (self, *, str|None path=None, str|None prefix=None, dict[str, str]|None labels=None, bool diff_gauge=False) |
Creates a MetricsDiffer that fetches metrics using this client. | |
| pytest_userver.metrics.MetricsSnapshot | metrics (self, *, str|None path=None, str|None prefix=None, dict[str, str]|None labels=None) |
| Returns a dict of metric names to Metric. | |
| pytest_userver.metrics.Metric|None | single_metric_optional (self, str path, *, dict[str, str]|None labels=None) |
| Either return a pytest_userver.metrics.Metric or None if there's no such metric. | |
| pytest_userver.metrics.Metric|None | single_metric (self, str path, *, dict[str, str]|None labels=None) |
| Returns the pytest_userver.metrics.Metric. | |
| dict[str, pytest_userver.metrics.Metric] | metrics_raw (self, str output_format, *, str|None path=None, str|None prefix=None, dict[str, str]|None labels=None) |
| Low level function that returns metrics in a specific format. | |
| get_metrics (self, prefix=None) | |
| get_metric (self, metric_name) | |
| fired_alerts (self) | |
| http.ClientResponse | post (self, str path, JsonAnyOptional json=None, Any data=None, dict[str, str]|None params=None, str|None bearer=None, str|None x_real_ip=None, dict[str, str]|None headers=None, **kwargs) |
| Make a HTTP POST request. | |
| http.ClientResponse | put (self, path, JsonAnyOptional json=None, Any data=None, dict[str, str]|None params=None, str|None bearer=None, str|None x_real_ip=None, dict[str, str]|None headers=None, **kwargs) |
| Make a HTTP PUT request. | |
| http.ClientResponse | patch (self, path, JsonAnyOptional json=None, Any data=None, dict[str, str]|None params=None, str|None bearer=None, str|None x_real_ip=None, dict[str, str]|None headers=None, **kwargs) |
| Make a HTTP PATCH request. | |
| http.ClientResponse | get (self, str path, dict[str, str]|None headers=None, str|None bearer=None, str|None x_real_ip=None, **kwargs) |
| Make a HTTP GET request. | |
| http.ClientResponse | delete (self, str path, dict[str, str]|None headers=None, str|None bearer=None, str|None x_real_ip=None, **kwargs) |
| Make a HTTP DELETE request. | |
| http.ClientResponse | options (self, str path, dict[str, str]|None headers=None, str|None bearer=None, str|None x_real_ip=None, **kwargs) |
| Make a HTTP OPTIONS request. | |
| http.ClientResponse | request (self, str http_method, str path, **kwargs) |
| Make a HTTP request with the specified method. | |
| raw_aiohttp_client (self) | |
Protected Member Functions | |
| Awaitable[http.ClientResponse] | _wrap_client_response (self, aiohttp.ClientResponse response) |
Protected Attributes | |
| _client = client | |
|
protectedinherited |
|
inherited |
|
inherited |
| pytest_userver.client.ClientMonitor.get_metric | ( | self, | |
| metric_name ) |
| pytest_userver.client.ClientMonitor.get_metrics | ( | self, | |
| prefix = None ) |
| pytest_userver.metrics.MetricsSnapshot pytest_userver.client.ClientMonitor.metrics | ( | self, | |
| * | , | ||
| str | None | path = None, | ||
| str | None | prefix = None, | ||
| dict[str, str] | None | labels = None ) |
Returns a dict of metric names to Metric.
| path | Optional full metric path |
| prefix | Optional prefix on which the metric paths should start |
| labels | Optional dictionary of labels that must be in the metric |
| MetricsDiffer pytest_userver.client.ClientMonitor.metrics_diff | ( | self, | |
| * | , | ||
| str | None | path = None, | ||
| str | None | prefix = None, | ||
| dict[str, str] | None | labels = None, | ||
| bool | diff_gauge = False ) |
Creates a MetricsDiffer that fetches metrics using this client.
It's recommended to use this method over metrics to make sure the tests don't affect each other.
With diff_gauge off, only RATE metrics are differentiated. With diff_gauge on, GAUGE metrics are differentiated as well, which may lead to nonsensical results for those.
| path | Optional full metric path |
| prefix | Optional prefix on which the metric paths should start |
| labels | Optional dictionary of labels that must be in the metric |
| diff_gauge | Whether to differentiate GAUGE metrics |
| dict[str, pytest_userver.metrics.Metric] pytest_userver.client.ClientMonitor.metrics_raw | ( | self, | |
| str | output_format, | ||
| * | , | ||
| str | None | path = None, | ||
| str | None | prefix = None, | ||
| dict[str, str] | None | labels = None ) |
Low level function that returns metrics in a specific format.
Use metrics and single_metric instead if possible.
| output_format | pytest_userver.metrics.Metric output format. See server.handlers.ServerMonitor for a list of supported formats. |
| path | Optional full metric path |
| prefix | Optional prefix on which the metric paths should start |
| labels | Optional dictionary of labels that must be in the metric |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
| pytest_userver.metrics.Metric | None pytest_userver.client.ClientMonitor.single_metric | ( | self, | |
| str | path, | ||
| * | , | ||
| dict[str, str] | None | labels = None ) |
Returns the pytest_userver.metrics.Metric.
| path | Full metric path |
| labels | Optional dictionary of labels that must be in the metric |
| AssertionError | if more than one metric or no metric found |
| pytest_userver.metrics.Metric | None pytest_userver.client.ClientMonitor.single_metric_optional | ( | self, | |
| str | path, | ||
| * | , | ||
| dict[str, str] | None | labels = None ) |
Either return a pytest_userver.metrics.Metric or None if there's no such metric.
| path | Full metric path |
| labels | Optional dictionary of labels that must be in the metric |
| AssertionError | if more than one metric returned |
|
protectedinherited |