pub struct StatisticsHandle { /* private fields */ }Expand description
A cheaply cloned handle for recording and reading crawl statistics.
Implementations§
Source§impl StatisticsHandle
impl StatisticsHandle
Sourcepub fn record_finished(
&self,
duration: Duration,
status_code: Option<u16>,
retry_count: u32,
)
pub fn record_finished( &self, duration: Duration, status_code: Option<u16>, retry_count: u32, )
Records a successful terminal request.
duration is the cumulative per-request processing time across all attempts.
Sourcepub fn record_failed(
&self,
duration: Duration,
error_key: &str,
retry_count: u32,
)
pub fn record_failed( &self, duration: Duration, error_key: &str, retry_count: u32, )
Records a terminally failed request.
duration is the cumulative per-request processing time across all attempts.
Sourcepub fn record_retry(&self, error_key: &str)
pub fn record_retry(&self, error_key: &str)
Records an error that caused a request retry.
Sourcepub fn mark_run_started(&self)
pub fn mark_run_started(&self)
Starts runtime measurement if it is not already running.
Sourcepub fn mark_run_stopped(&self)
pub fn mark_run_stopped(&self)
Stops runtime measurement if it is running and accumulates the elapsed time.
Sourcepub fn snapshot(&self) -> StatisticsSnapshot
pub fn snapshot(&self) -> StatisticsSnapshot
Returns a point-in-time copy of the current statistics.
Sourcepub fn subscribe(&self) -> Receiver<StatisticsSnapshot>
pub fn subscribe(&self) -> Receiver<StatisticsSnapshot>
Subscribes to live snapshots emitted after statistics are recorded.
Updates are best effort: a slow receiver may skip intermediate snapshots, while a later record operation will still deliver the newest state once capacity is available. When called from within a Tokio runtime, snapshots are also emitted periodically. Outside a runtime, the receiver remains usable for snapshots triggered by record operations.
Sourcepub fn finalize(&self) -> FinalStatistics
pub fn finalize(&self) -> FinalStatistics
Returns the current statistics in their final run-result form.
Sourcepub async fn persist(&self, kvs: &dyn KeyValueStore) -> StorageResult<()>
pub async fn persist(&self, kvs: &dyn KeyValueStore) -> StorageResult<()>
Persists lossless accumulator state to a key-value store.
Sourcepub async fn restore(&self, kvs: &dyn KeyValueStore) -> StorageResult<bool>
pub async fn restore(&self, kvs: &dyn KeyValueStore) -> StorageResult<bool>
Restores persisted accumulator state, returning whether the key existed.
Sliding-window events are intentionally not restored, and runtime resumes stopped.
Trait Implementations§
Source§impl Clone for StatisticsHandle
impl Clone for StatisticsHandle
Source§fn clone(&self) -> StatisticsHandle
fn clone(&self) -> StatisticsHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more