Counter

Inheritance diagram of Counter

Counter inheritance diagram

class savant.metrics.Counter(name, description='', labelnames=())

Counter metric.

Usage example:

counter = Counter(
    name='frames_per_source',
    description='Number of processed frames per source',
    labelnames=('source_id',),
)
counter.inc(labels=('camera-1',))
inc(amount=1, labels=(), timestamp=None)

Increment counter by amount.

Parameters:
  • amount – Increment amount.

  • labels (Tuple[str, ...]) – Labels values.

  • timestamp (float | None) – Metric timestamp.

set(value, labels=(), timestamp=None)

Set counter to specific value.

Parameters:
  • value – Counter value. Must be non-decreasing.

  • labels (Tuple[str, ...]) – Labels values.

  • timestamp (float | None) – Metric timestamp.

property description: str

Metric description.

property labelnames: Tuple[str, ...]

Metric label names.

property name: str

Metric name.

property values: Dict[Tuple[str, ...], Tuple[float, float]]

Metric values.

Returns:

Dictionary: labels -> (value, timestamp).