pub struct ObservationLog {
pub max_age_secs: u64,
/* private fields */
}Expand description
Append-only, TTL-pruned observation log backed by redb.
Fields§
§max_age_secs: u64Implementations§
Source§impl ObservationLog
impl ObservationLog
Sourcepub fn open(path: &Path, max_age_secs: u64) -> Result<Self, ObsLogError>
pub fn open(path: &Path, max_age_secs: u64) -> Result<Self, ObsLogError>
Open or create an observation log at the given path.
Sourcepub fn append(
&self,
source: &str,
value: f64,
metadata: BTreeMap<String, String>,
) -> Result<(), ObsLogError>
pub fn append( &self, source: &str, value: f64, metadata: BTreeMap<String, String>, ) -> Result<(), ObsLogError>
Append a single observation.
Sourcepub fn append_batch(
&self,
observations: &[(String, f64, BTreeMap<String, String>)],
) -> Result<(), ObsLogError>
pub fn append_batch( &self, observations: &[(String, f64, BTreeMap<String, String>)], ) -> Result<(), ObsLogError>
Append a batch of observations in a single transaction.
Sourcepub fn query(
&self,
source: &str,
since_ts_ms: u64,
) -> Result<Vec<Observation>, ObsLogError>
pub fn query( &self, source: &str, since_ts_ms: u64, ) -> Result<Vec<Observation>, ObsLogError>
Query observations for a source since a given timestamp.
Sourcepub fn query_latest(
&self,
source: &str,
) -> Result<Option<Observation>, ObsLogError>
pub fn query_latest( &self, source: &str, ) -> Result<Option<Observation>, ObsLogError>
Get the most recent observation for a source.
Sourcepub fn sources(&self) -> Result<Vec<String>, ObsLogError>
pub fn sources(&self) -> Result<Vec<String>, ObsLogError>
List distinct sources that have observations.
Sourcepub fn truncate(&self, before_ts_ms: u64) -> Result<u64, ObsLogError>
pub fn truncate(&self, before_ts_ms: u64) -> Result<u64, ObsLogError>
Delete all observations older than before_ts_ms. Returns count deleted.
Sourcepub fn count(&self) -> Result<u64, ObsLogError>
pub fn count(&self) -> Result<u64, ObsLogError>
Total number of observations.
Sourcepub fn size_bytes(&self) -> u64
pub fn size_bytes(&self) -> u64
Size of the redb file in bytes.
Auto Trait Implementations§
impl Freeze for ObservationLog
impl !RefUnwindSafe for ObservationLog
impl Send for ObservationLog
impl Sync for ObservationLog
impl Unpin for ObservationLog
impl UnsafeUnpin for ObservationLog
impl !UnwindSafe for ObservationLog
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