snoozeml.metrics — Prometheus Metrics Parsing & Telemetry#

Structured Prometheus metrics parser for the SnoozeML inference daemon.

Parses the text exposition output of GET /metrics (src/server/metrics.rs) into a typed DaemonMetrics object for programmatic monitoring, alerting, and notebook telemetry.

class snoozeml.metrics.DaemonMetrics(requests_total=0, requests_success=0, requests_error=0, inference_latency_seconds_total=0.0, batches_dispatched_total=0, oom_deallocations_total=0, idle_deallocations_total=0, capacity_deallocations_total=0, model_load_retries_total=0, deallocation_thrashing_total=0, stream_messages_consumed_total=0, stream_messages_published_total=0, stream_errors_total=0, raw_metrics=<factory>)[source]#

Bases: object

Structured snapshot of SnoozeML operational counters parsed from GET /metrics.

Parameters:
  • requests_total (int)

  • requests_success (int)

  • requests_error (int)

  • inference_latency_seconds_total (float)

  • batches_dispatched_total (int)

  • oom_deallocations_total (int)

  • idle_deallocations_total (int)

  • capacity_deallocations_total (int)

  • model_load_retries_total (int)

  • deallocation_thrashing_total (int)

  • stream_messages_consumed_total (int)

  • stream_messages_published_total (int)

  • stream_errors_total (int)

  • raw_metrics (Dict[str, float])

requests_total#

Total inference requests received across all statuses.

Type:

int

requests_success#

Total successful inference completions.

Type:

int

requests_error#

Total failed inference requests.

Type:

int

inference_latency_seconds_total#

Cumulative server-side inference latency in seconds.

Type:

float

batches_dispatched_total#

Total dynamic micro-batches executed by the batcher.

Type:

int

oom_deallocations_total#

Total reactive model unloads triggered by OOM recovery.

Type:

int

idle_deallocations_total#

Total scale-to-zero unloads triggered by the idle sweeper.

Type:

int

capacity_deallocations_total#

Total LRU unloads triggered by max_loaded_models caps.

Type:

int

model_load_retries_total#

Total allocation retry attempts after OOM eviction.

Type:

int

deallocation_thrashing_total#

Total rapid re-deallocation thrashing events detected.

Type:

int

stream_messages_consumed_total#

Total messages ingested from streaming brokers.

Type:

int

stream_messages_published_total#

Total messages published to streaming brokers.

Type:

int

stream_errors_total#

Total errors encountered during streaming ingestion or egress.

Type:

int

raw_metrics#

Dictionary of all parsed metric keys (with normalized labels) to float values.

Type:

Dict[str, float]

requests_total: int = 0#
requests_success: int = 0#
requests_error: int = 0#
inference_latency_seconds_total: float = 0.0#
batches_dispatched_total: int = 0#
oom_deallocations_total: int = 0#
idle_deallocations_total: int = 0#
capacity_deallocations_total: int = 0#
model_load_retries_total: int = 0#
deallocation_thrashing_total: int = 0#
stream_messages_consumed_total: int = 0#
stream_messages_published_total: int = 0#
stream_errors_total: int = 0#
raw_metrics: Dict[str, float]#
property average_latency_ms: float#

Average server-side inference latency in milliseconds (0.0 if no requests recorded).

property success_rate: float#

Fraction of successful inference requests in [0.0, 1.0] (1.0 if no requests recorded).

property total_deallocations: int#

Sum of idle, capacity, and OOM model deallocations.

to_dict()[source]#

Serializes this DaemonMetrics snapshot into a dictionary.

Return type:

Dict[str, Any]

classmethod from_prometheus(text)[source]#

Parses Prometheus exposition text from GET /metrics into a DaemonMetrics instance.

Parameters:

text (str) – Raw Prometheus exposition string returned by the SnoozeML server.

Returns:

Populated DaemonMetrics snapshot.

Return type:

DaemonMetrics

snoozeml.metrics.parse_prometheus_metrics(text)[source]#

Convenience function that parses Prometheus exposition text into DaemonMetrics.

Parameters:

text (str)

Return type:

DaemonMetrics