Skip to content

API Reference parrot.storage.instrumented

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

parrot.storage.instrumented

View source

InstrumentedBackend — transparent ConversationBackend wrapper.

Wraps any ConversationBackend and records per-method latency and errors via a StorageMetrics instance. Zero overhead when PARROT_STORAGE_METRICS is unset (the factory returns the raw backend in that case).

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

Alias ConversationBackend

Re-exported from parrot.storage.backends.base.ConversationBackend.

Class InstrumentedBackend

Wraps any ConversationBackend and records per-method latency + errors.

The wrapper delegates every abstract method to the inner backend while timing the call and reporting to the configured StorageMetrics instance.

is_connected and build_overflow_prefix pass through without timing since they are synchronous and zero-cost.

Parameter Type Default Description
inner ConversationBackend Any ConversationBackend implementation.
metrics Optional[StorageMetrics] None Optional StorageMetrics instance. Defaults to no-op.

Attributes:

Attribute Type Description
is_connected bool

Method InstrumentedBackend.initialize

initialize() -> None

Method InstrumentedBackend.close

close() -> None

Method InstrumentedBackend.build_overflow_prefix

build_overflow_prefix(user_id: str, agent_id: str, session_id: str, artifact_id: str) -> str

Parameter Type Default Description
user_id str
agent_id str
session_id str
artifact_id str

Returns: str

Method InstrumentedBackend.put_thread

put_thread(*a, **kw) -> None

Parameter Type Default Description
*a ()
**kw {}

Method InstrumentedBackend.update_thread

update_thread(*a, **kw) -> None

Parameter Type Default Description
*a ()
**kw {}

Method InstrumentedBackend.query_threads

query_threads(*a, **kw) -> List[dict]

Parameter Type Default Description
*a ()
**kw {}

Returns: List[dict]

Method InstrumentedBackend.put_turn

put_turn(*a, **kw) -> dict

Parameter Type Default Description
*a ()
**kw {}

Returns: dict

Method InstrumentedBackend.query_turns

query_turns(*a, **kw) -> List[dict]

Parameter Type Default Description
*a ()
**kw {}

Returns: List[dict]

Method InstrumentedBackend.delete_turn

delete_turn(*a, **kw) -> bool

Parameter Type Default Description
*a ()
**kw {}

Returns: bool

Method InstrumentedBackend.delete_thread_cascade

delete_thread_cascade(*a, **kw) -> int

Parameter Type Default Description
*a ()
**kw {}

Returns: int

Method InstrumentedBackend.query_turn_window

query_turn_window(*a, **kw) -> List[dict]

Parameter Type Default Description
*a ()
**kw {}

Returns: List[dict]

Method InstrumentedBackend.max_sequence

max_sequence(*a, **kw) -> int

Parameter Type Default Description
*a ()
**kw {}

Returns: int

Method InstrumentedBackend.put_tombstone

put_tombstone(*a, **kw) -> None

Parameter Type Default Description
*a ()
**kw {}

Method InstrumentedBackend.deleted_turn_ids

deleted_turn_ids(*a, **kw)

Parameter Type Default Description
*a ()
**kw {}

Method InstrumentedBackend.deleted_session_ids

deleted_session_ids(*a, **kw)

Parameter Type Default Description
*a ()
**kw {}

Method InstrumentedBackend.is_deleted

is_deleted(*a, **kw) -> bool

Parameter Type Default Description
*a ()
**kw {}

Returns: bool

Method InstrumentedBackend.get_index_state

get_index_state(*a, **kw) -> str

Parameter Type Default Description
*a ()
**kw {}

Returns: str

Method InstrumentedBackend.backfill_batch

backfill_batch(*a, **kw)

Parameter Type Default Description
*a ()
**kw {}

Method InstrumentedBackend.put_artifact

put_artifact(*a, **kw) -> None

Parameter Type Default Description
*a ()
**kw {}

Method InstrumentedBackend.get_artifact

get_artifact(*a, **kw) -> Optional[dict]

Parameter Type Default Description
*a ()
**kw {}

Returns: Optional[dict]

Method InstrumentedBackend.query_artifacts

query_artifacts(*a, **kw) -> List[dict]

Parameter Type Default Description
*a ()
**kw {}

Returns: List[dict]

Method InstrumentedBackend.delete_artifact

delete_artifact(*a, **kw) -> None

Parameter Type Default Description
*a ()
**kw {}

Method InstrumentedBackend.delete_session_artifacts

delete_session_artifacts(*a, **kw) -> int

Parameter Type Default Description
*a ()
**kw {}

Returns: int

Alias NoopStorageMetrics

Re-exported from parrot.storage.metrics.NoopStorageMetrics.

Alias StorageMetrics

Re-exported from parrot.storage.metrics.StorageMetrics.

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