VideoIngestFragmentMetric

Thread-safe rolling statistics tracker for numeric metrics associated with a key.

Attributes:
  • key (str) –

    Logical identifier for the source of the metric (e.g., Camera.id).

  • name (str) –

    Name of the metric (e.g., "kafka_consume_age").

  • max_items (int) –

    Maximum number of records to retain in the rolling window (default is 100).

append(value)

Append a new numeric observation to the rolling window.

Parameters:
  • value (float) –

    New metric value to store.

get_avg()

Return the average of the current metric window.

Returns:
  • float( float ) –

    Average value, or 0.0 if no data is available.

get_percentile(percentile)

Return the specified percentile of the current metric window.

Parameters:
  • percentile (float) –

    Percentile to compute (e.g., 99.0).

Returns:
  • float( float ) –

    Computed percentile value, or 0.0 if no data is available.

get_stats()

Get summary statistics over the current record window.

Returns:
  • Dict[str, float]

    Dict[str, float]: Dictionary containing: - "avg": Average value. - "p99": 99th percentile.

threshold_exceeded(threshold)

Check whether the current average value exceeds a threshold.

Parameters:
  • threshold (float) –

    Threshold to compare against.

Returns:
  • bool( bool ) –

    True if the average value exceeds the threshold, False otherwise.