Taking structured events beyond memory
RelPrim already exposes structured lifecycle events for retries, fallbacks, validation, circuit breakers, rate limits and operation outcomes.
Version 0.10.0 adds two ways to use those events outside the process itself: OpenTelemetry export and durable SQLite history.
Export events to OpenTelemetry
OpenTelemetryEventSink adds RelPrim events to the currently active
OpenTelemetry span.
from relprim import EventEmitter, resilient
from relprim.opentelemetry import OpenTelemetryEventSink
event_emitter = EventEmitter(
sinks=(OpenTelemetryEventSink(),)
)
@resilient(
retries=3,
timeout=10,
events=event_emitter,
)
async def call_provider(prompt: str) -> str:
return await provider.generate(prompt)
The application remains responsible for creating the span and configuring its OpenTelemetry SDK and exporter.
RelPrim only contributes its reliability events to the existing trace.
Persist events in SQLite
The same structured events can now be kept locally with SQLiteEventStore.
from relprim import EventEmitter, SQLiteEventStore
event_store = SQLiteEventStore(
"relprim-events.db"
)
event_emitter = EventEmitter(
sinks=(event_store,)
)
Events survive process restarts and can be queried later:
history = await event_store.history(
operation_name="call_provider",
limit=100,
)
for stored in history:
print(
stored.sequence_id,
stored.event.to_dict(),
)
History can also be filtered by event type and paginated using the stored sequence ID.
Retention without hidden workers
Old history can be removed explicitly:
from datetime import UTC, datetime, timedelta
deleted = await event_store.delete_before(
datetime.now(UTC) - timedelta(days=30)
)
RelPrim does not start a background cleanup task or silently manage retention. The application decides when deletion should happen.
Use both together
SQLite and OpenTelemetry implement the same event-sink abstraction, so they can be composed:
event_emitter = EventEmitter(
sinks=(
SQLiteEventStore("relprim-events.db"),
OpenTelemetryEventSink(),
)
)
One event can therefore become part of a distributed trace while also remaining available in local durable history.
Scope
The SQLite store is designed for local and single-host persistence, debugging and lightweight execution history. It is not a distributed event database or an event-sourcing framework.
The OpenTelemetry integration exports events to existing spans. It does not configure tracing infrastructure or ship an observability backend.
Both integrations stay behind the existing EventEmitter abstraction, keeping
the core execution API unchanged.
