userver: pytest_userver.client.ClientMonitor Class Reference
Loading...
Searching...
No Matches
pytest_userver.client.ClientMonitor Class Reference

Detailed Description

Asyncio userver client for monitor listeners, typically retrieved from plugins.service_client.monitor_client fixture.

Compatible with werkzeug interface.

Definition at line 376 of file client.py.

+ Inheritance diagram for pytest_userver.client.ClientMonitor:
+ Collaboration diagram for pytest_userver.client.ClientMonitor:

Public Member Functions

'MetricsDiffermetrics_diff (self, *typing.Optional[str] path=None, typing.Optional[str] prefix=None, typing.Optional[typing.Dict[str, str]] labels=None, bool diff_gauge=False)
 Creates a MetricsDiffer that fetches metrics using this client.
 
metric_module.MetricsSnapshot metrics (self, *typing.Optional[str] path=None, typing.Optional[str] prefix=None, typing.Optional[typing.Dict[str, str]] labels=None)
 Returns a dict of metric names to Metric.
 
typing.Optional[Metric] single_metric_optional (self, str path, *typing.Optional[typing.Dict[str, str]] labels=None)
 Either return a Metric or None if there's no such metric.
 
typing.Optional[Metric] single_metric (self, str path, *typing.Optional[typing.Dict[str, str]] labels=None)
 Returns the Metric.
 
typing.Dict[str, Metric] metrics_raw (self, str output_format, *typing.Optional[str] path=None, typing.Optional[str] prefix=None, typing.Optional[typing.Dict[str, str]] 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)
 
- Public Member Functions inherited from pytest_userver.client.ClientWrapper
 __init__ (self, client)
 
http.ClientResponse post (self, str path, annotations.JsonAnyOptional json=None, typing.Any data=None, typing.Optional[typing.Dict[str, str]] params=None, typing.Optional[str] bearer=None, typing.Optional[str] x_real_ip=None, typing.Optional[typing.Dict[str, str]] headers=None, **kwargs)
 Make a HTTP POST request.
 
http.ClientResponse put (self, path, annotations.JsonAnyOptional json=None, typing.Any data=None, typing.Optional[typing.Dict[str, str]] params=None, typing.Optional[str] bearer=None, typing.Optional[str] x_real_ip=None, typing.Optional[typing.Dict[str, str]] headers=None, **kwargs)
 Make a HTTP PUT request.
 
http.ClientResponse patch (self, path, annotations.JsonAnyOptional json=None, typing.Any data=None, typing.Optional[typing.Dict[str, str]] params=None, typing.Optional[str] bearer=None, typing.Optional[str] x_real_ip=None, typing.Optional[typing.Dict[str, str]] headers=None, **kwargs)
 Make a HTTP PATCH request.
 
http.ClientResponse get (self, str path, typing.Optional[typing.Dict[str, str]] headers=None, typing.Optional[str] bearer=None, typing.Optional[str] x_real_ip=None, **kwargs)
 Make a HTTP GET request.
 
http.ClientResponse delete (self, str path, typing.Optional[typing.Dict[str, str]] headers=None, typing.Optional[str] bearer=None, typing.Optional[str] x_real_ip=None, **kwargs)
 Make a HTTP DELETE request.
 
http.ClientResponse options (self, str path, typing.Optional[typing.Dict[str, str]] headers=None, typing.Optional[str] bearer=None, typing.Optional[str] 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.
 

Additional Inherited Members

- Protected Member Functions inherited from pytest_userver.client.ClientWrapper
typing.Awaitable[http.ClientResponse] _wrap_client_response (self, aiohttp.ClientResponse response)
 
- Protected Attributes inherited from pytest_userver.client.ClientWrapper
 _client
 

Member Function Documentation

◆ fired_alerts()

pytest_userver.client.ClientMonitor.fired_alerts ( self)

Definition at line 516 of file client.py.

◆ get_metric()

pytest_userver.client.ClientMonitor.get_metric ( self,
metric_name )
Deprecated
Use metrics() or single_metric() instead

Definition at line 509 of file client.py.

◆ get_metrics()

pytest_userver.client.ClientMonitor.get_metrics ( self,
prefix = None )
Deprecated
Use metrics() or single_metric() instead

Definition at line 502 of file client.py.

◆ metrics()

metric_module.MetricsSnapshot pytest_userver.client.ClientMonitor.metrics ( self,
*typing.Optional[str] path = None,
typing.Optional[str] prefix = None,
typing.Optional[typing.Dict[str, str]] labels = None )

Returns a dict of metric names to Metric.

Parameters
pathOptional full metric path
prefixOptional prefix on which the metric paths should start
labelsOptional dictionary of labels that must be in the metric

Definition at line 423 of file client.py.

◆ metrics_diff()

'MetricsDiffer' pytest_userver.client.ClientMonitor.metrics_diff ( self,
*typing.Optional[str] path = None,
typing.Optional[str] prefix = None,
typing.Optional[typing.Dict[str, str]] 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.

Parameters
pathOptional full metric path
prefixOptional prefix on which the metric paths should start
labelsOptional dictionary of labels that must be in the metric
diff_gaugeWhether to differentiate GAUGE metrics
async with monitor_client.metrics_diff(prefix='foo') as differ:
# Do something that makes the service update its metrics
assert differ.value_at('path-suffix', {'label'}) == 42

Definition at line 386 of file client.py.

◆ metrics_raw()

typing.Dict[str, Metric] pytest_userver.client.ClientMonitor.metrics_raw ( self,
str output_format,
*typing.Optional[str] path = None,
typing.Optional[str] prefix = None,
typing.Optional[typing.Dict[str, str]] labels = None )

Low level function that returns metrics in a specific format.

Use metrics and single_metric instead if possible.

Parameters
output_formatMetric output format. See server::handlers::ServerMonitor for a list of supported formats.
pathOptional full metric path
prefixOptional prefix on which the metric paths should start
labelsOptional dictionary of labels that must be in the metric

Definition at line 476 of file client.py.

◆ single_metric()

typing.Optional[Metric] pytest_userver.client.ClientMonitor.single_metric ( self,
str path,
*typing.Optional[typing.Dict[str, str]] labels = None )

Returns the Metric.

Parameters
pathFull metric path
labelsOptional dictionary of labels that must be in the metric
Exceptions
AssertionErrorif more than one metric or no metric found

Definition at line 459 of file client.py.

◆ single_metric_optional()

typing.Optional[Metric] pytest_userver.client.ClientMonitor.single_metric_optional ( self,
str path,
*typing.Optional[typing.Dict[str, str]] labels = None )

Either return a Metric or None if there's no such metric.

Parameters
pathFull metric path
labelsOptional dictionary of labels that must be in the metric
Exceptions
AssertionErrorif more than one metric returned

Definition at line 442 of file client.py.


The documentation for this class was generated from the following file: