Skip to content

API Reference parrot.storage.metrics

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.storage.metrics

View source

StorageMetrics protocol and no-op default implementation.

Defines the two-method observability seam used by InstrumentedBackend. Production callers plug in their own adapter (Prometheus, OpenTelemetry, statsd) by implementing this protocol and pointing PARROT_STORAGE_METRICS at a module-level instance.

FEAT-116: dynamodb-fallback-redis — Module 8 (observability hooks).

Class NoopStorageMetrics

Default metrics implementation — records nothing.

Used when PARROT_STORAGE_METRICS is unset (the common case). Zero overhead: every method is a Python ... no-op.

Method NoopStorageMetrics.record_latency

record_latency(backend_name: str, method: str, duration_ms: float) -> None

Parameter Type Default Description
backend_name str
method str
duration_ms float

Method NoopStorageMetrics.record_error

record_error(backend_name: str, method: str, error_type: str) -> None

Parameter Type Default Description
backend_name str
method str
error_type str

Class StorageMetrics

Protocol for storage-backend metric collection.

Implementers plug in Prometheus / OpenTelemetry / statsd in their own code. AI-Parrot ships a no-op default and an InstrumentedBackend wrapper that calls these methods around every backend operation.

Example Prometheus adapter — see wiki/stores/storage-backends.md §Observability.

Method StorageMetrics.record_latency

Record the latency of a single backend method call.

record_latency(backend_name: str, method: str, duration_ms: float) -> None

Parameter Type Default Description
backend_name str Class name of the backend (e.g. "ConversationSQLiteBackend").
method str Name of the method called (e.g. "put_thread").
duration_ms float Wall-clock duration in milliseconds.

Method StorageMetrics.record_error

Record that a backend method raised an exception.

record_error(backend_name: str, method: str, error_type: str) -> None

Parameter Type Default Description
backend_name str Class name of the backend.
method str Name of the method that raised.
error_type str type(exc).__name__ of the exception.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally