squirrel.iterstream.metrics

There are two metrics used in squirrel.iterstream.base.Composable.monitor(): metrics_iops() and metrics_throughput(). They can be turned on and off by passing an instance of MetricsConf to monitor(..., metrics_conf=MetricsConf(...)) whenever it is being used.

Note

Both metrics are turned on be default. When one metric is on and the other is off, the labels of both metrics will still be returned, but the actual value of the turned-off metric will be reported as 0. When both are turned off, none will be handed over to the callback, and the original iterator simply passes through the method monitor.

The APIs of these functions and class are listed below:

Module Contents

Classes

MetricsConf

A config data class controls 3 things: 1) whether the metric IOPS is calculated. 2) whether the metric throughput

Functions

metrics_iops(→ float)

Returns number of items per second based on number of items and duration.

metrics_throughput(→ float)

Returns bytes IO per second based on the total size of items and duration.

Attributes

logger

squirrel.iterstream.metrics.logger
class squirrel.iterstream.metrics.MetricsConf

A config data class controls 3 things: 1) whether the metric IOPS is calculated. 2) whether the metric throughput is calculated 3) and which throughput unit is being used.

Parameters
  • iops (bool) – If true, metrics_iops will be used and calculate

  • throughput (bool) – If true, metrics_throughput will be used and calculated

  • throughput_unit (str) – Defaults to bytes. Other valid units include ‘KB’, ‘MB’, ‘GB’.

iops :bool = True
throughput :bool = True
throughput_unit :str = MB
asdict()Dict

Returns the sample as a dictionary

squirrel.iterstream.metrics.metrics_iops(count: int, duration: float)float

Returns number of items per second based on number of items and duration.

squirrel.iterstream.metrics.metrics_throughput(size: float, duration: float, unit: str = 'bytes')float

Returns bytes IO per second based on the total size of items and duration.