StorageTracker

Struct StorageTracker 

Source
pub struct StorageTracker { /* private fields */ }
Expand description

Real-time storage statistics tracker.

Maintains in-memory counters that are updated on every write operation. Thread-safe via RwLock for concurrent access.

Implementations§

Source§

impl StorageTracker

Source

pub fn total_stats(&self) -> TierStats

Get total storage stats across all tiers.

Source

pub fn stats_by_type(&self, tier: Tier) -> HashMap<KeyKind, StorageStats>

Get stats aggregated by KeyKind for a specific tier.

Source

pub fn stats_by_type_all_tiers(&self) -> HashMap<KeyKind, TierStats>

Get stats aggregated by KeyKind across all tiers.

Source

pub fn stats_for_object(&self, object_id: ObjectId) -> Option<TierStats>

Get stats for a specific object across all tiers.

Source

pub fn objects_by_tier(&self, tier: Tier) -> Vec<(ObjectId, StorageStats)>

Get all objects for a specific tier, sorted by total bytes descending.

Source

pub fn top_objects_by_size(&self, n: usize) -> Vec<(ObjectId, TierStats)>

Get top N objects by total storage consumption across all tiers.

Source

pub fn config(&self) -> StorageTrackerConfig

Get configuration.

Source§

impl StorageTracker

Source

pub fn new(config: StorageTrackerConfig) -> StorageTracker

Create a new storage tracker with the given configuration.

Source

pub fn with_defaults() -> StorageTracker

Create a new tracker with default configuration.

Source

pub fn record_write( &self, tier: Tier, key: &[u8], key_bytes: u64, value_bytes: u64, pre_version: Option<PreVersionInfo>, )

Record a write operation (insert or update).

  • tier: Which storage tier this write goes to
  • key: The encoded key bytes (unversioned, used for KeyKind lookup)
  • key_bytes: Size of the key as stored (typically versioned key size)
  • value_bytes: Size of the value being written
  • pre_version: Information about the previous version, if the key already existed
Source

pub fn record_delete( &self, tier: Tier, key: &[u8], key_bytes: u64, pre_version: Option<PreVersionInfo>, )

Record a delete operation (tombstone).

  • tier: Which storage tier this delete goes to
  • key: The encoded key bytes (unversioned, used for KeyKind lookup)
  • key_bytes: Size of the tombstone key as stored (typically versioned key size)
  • pre_version: Information about the previous version being deleted
Source

pub fn record_drop( &self, tier: Tier, key: &[u8], versioned_key_bytes: u64, value_bytes: u64, )

Record a drop operation (physical removal of historical version entry).

Unlike delete, drop doesn’t create tombstones - it physically removes entries from storage. Used for MVCC cleanup of old versions.

  • tier: Which storage tier the drop occurred in
  • key: The original (unversioned) encoded key bytes
  • versioned_key_bytes: Size of the versioned key being dropped
  • value_bytes: Size of the value being dropped
Source

pub fn record_cdc_for_change( &self, tier: Tier, key: &[u8], value_bytes: u64, count: u64, )

Record CDC bytes for a specific change.

Called for each change in a CDC entry to attribute bytes to the source object.

  • tier: Which storage tier the CDC entry was written to
  • key: The change key (identifies the source object)
  • value_bytes: Bytes attributed to this change (distributed overhead)
  • count: Number of CDC entries to record (typically 1)
Source

pub fn record_tier_migration( &self, from_tier: Tier, to_tier: Tier, key: &[u8], value_bytes: u64, is_current: bool, )

Record data migration between tiers.

When data moves from one tier to another (e.g., hot -> warm), this updates the stats for both tiers.

Source

pub fn should_checkpoint(&self) -> bool

Check if a checkpoint is needed based on elapsed time.

Source

pub async fn checkpoint_async<S>(&self, storage: &S) -> Result<(), Error>

Persist current stats to storage.

Writes all tracked stats to the storage using KeyKind::StorageTracker keys.

Source

pub async fn restore_async<S>( storage: &S, config: StorageTrackerConfig, ) -> Result<StorageTracker, Error>

Restore stats from storage on startup.

Loads previously persisted stats from storage using KeyKind::StorageTracker keys.

Trait Implementations§

Source§

impl Clone for StorageTracker

Source§

fn clone(&self) -> StorageTracker

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StorageTracker

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more