pub struct SqliteTelemetryStore { /* private fields */ }Expand description
A TelemetryStore backed by an embedded SQLite database.
All data (metrics, events, snapshots) is persisted to a single SQLite file
and can be queried by timestamp range. A configurable RetentionPolicy
controls automatic purging of old data.
Implementations§
Source§impl SqliteTelemetryStore
impl SqliteTelemetryStore
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self, TelemetryError>
pub fn open(path: impl AsRef<Path>) -> Result<Self, TelemetryError>
Open (or create) a SQLite telemetry store at the given path.
Sourcepub fn open_with_retention(
path: impl AsRef<Path>,
retention: RetentionPolicy,
) -> Result<Self, TelemetryError>
pub fn open_with_retention( path: impl AsRef<Path>, retention: RetentionPolicy, ) -> Result<Self, TelemetryError>
Open with a custom retention policy.
Sourcepub fn in_memory() -> Result<Self, TelemetryError>
pub fn in_memory() -> Result<Self, TelemetryError>
Create an in-memory SQLite store (useful for testing).
Sourcepub const fn set_retention(&mut self, retention: RetentionPolicy)
pub const fn set_retention(&mut self, retention: RetentionPolicy)
Set the retention policy.
Sourcepub fn apply_retention(&mut self) -> Result<RetentionStats, TelemetryError>
pub fn apply_retention(&mut self) -> Result<RetentionStats, TelemetryError>
Apply the retention policy, deleting records older than the configured thresholds.
Sourcepub fn stats(&self) -> Result<StoreStats, TelemetryError>
pub fn stats(&self) -> Result<StoreStats, TelemetryError>
Return database statistics.
Trait Implementations§
Source§impl TelemetryStore for SqliteTelemetryStore
impl TelemetryStore for SqliteTelemetryStore
fn write_metric(&mut self, sample: MetricSample) -> Result<(), TelemetryError>
fn latest_metrics(&self) -> Result<Vec<MetricSample>, TelemetryError>
fn metrics_between( &self, from: &str, to: &str, ) -> Result<Vec<MetricSample>, TelemetryError>
fn write_event(&mut self, event: DockerEvent) -> Result<(), TelemetryError>
fn events_between( &self, from: &str, to: &str, ) -> Result<Vec<DockerEvent>, TelemetryError>
fn write_snapshot( &mut self, snapshot: TelemetrySnapshot, ) -> Result<(), TelemetryError>
fn snapshot_at_or_before( &self, timestamp: &str, ) -> Result<Option<TelemetrySnapshot>, TelemetryError>
fn all_snapshots(&self) -> Result<Vec<TelemetrySnapshot>, TelemetryError>
fn write_alert_event( &mut self, event: AlertHistoryEvent, ) -> Result<(), TelemetryError>
fn alert_history( &self, from: &str, to: &str, ) -> Result<Vec<AlertHistoryEvent>, TelemetryError>
Auto Trait Implementations§
impl !Freeze for SqliteTelemetryStore
impl !RefUnwindSafe for SqliteTelemetryStore
impl Send for SqliteTelemetryStore
impl !Sync for SqliteTelemetryStore
impl Unpin for SqliteTelemetryStore
impl UnsafeUnpin for SqliteTelemetryStore
impl !UnwindSafe for SqliteTelemetryStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more