pub struct Metrics {
pub pages_crawled: AtomicU64,
pub pages_failed: AtomicU64,
pub findings_generated: AtomicU64,
pub bytes_fetched: AtomicU64,
pub fetch_time_us: AtomicU64,
pub analysis_time_us: AtomicU64,
pub storage_time_us: AtomicU64,
pub active_connections: AtomicU64,
pub circuit_breaker_trips: AtomicU64,
pub resource_limit_hits: AtomicU64,
pub pages_skipped_circuit_breaker: AtomicU64,
}Expand description
Observability metrics for crawl operations.
Thread-safe metrics collection using atomic operations.
Designed for zero-allocation in hot paths. All counters use
Relaxed ordering for maximum throughput.
§Examples
use crawlkit_engine::Metrics;
use std::time::Duration;
let metrics = Metrics::new();
metrics.record_page_success(1024, 100, 50, 10, 3);
assert_eq!(metrics.pages_crawled.load(std::sync::atomic::Ordering::Relaxed), 1);Fields§
§pages_crawled: AtomicU64Total pages crawled.
pages_failed: AtomicU64Total pages failed.
findings_generated: AtomicU64Total findings generated.
bytes_fetched: AtomicU64Total bytes fetched.
fetch_time_us: AtomicU64Total fetch time (microseconds).
analysis_time_us: AtomicU64Total analysis time (microseconds).
storage_time_us: AtomicU64Total storage write time (microseconds).
active_connections: AtomicU64Active connections.
circuit_breaker_trips: AtomicU64Total circuit breaker trips (transitions to Open state).
resource_limit_hits: AtomicU64Total resource limit hits.
pages_skipped_circuit_breaker: AtomicU64Pages skipped due to circuit breaker being open.
Implementations§
Source§impl Metrics
impl Metrics
Sourcepub fn record_page_success(
&self,
bytes: u64,
fetch_us: u64,
analysis_us: u64,
storage_us: u64,
findings: u64,
)
pub fn record_page_success( &self, bytes: u64, fetch_us: u64, analysis_us: u64, storage_us: u64, findings: u64, )
Record a successful page crawl.
Sourcepub fn record_page_failure(&self)
pub fn record_page_failure(&self)
Record a failed page crawl.
Sourcepub fn record_circuit_breaker_trip(&self)
pub fn record_circuit_breaker_trip(&self)
Record a circuit breaker trip (transition to Open state).
Sourcepub fn record_resource_limit_hit(&self)
pub fn record_resource_limit_hit(&self)
Record a resource limit being hit.
Sourcepub fn record_page_skipped_circuit_breaker(&self)
pub fn record_page_skipped_circuit_breaker(&self)
Record a page skipped because the circuit breaker was open.
Sourcepub fn inc_connections(&self)
pub fn inc_connections(&self)
Increment active connections.
Sourcepub fn dec_connections(&self)
pub fn dec_connections(&self)
Decrement active connections.
Uses fetch_update to prevent underflow below zero.
Sourcepub fn pages_per_second(&self, elapsed: Duration) -> f64
pub fn pages_per_second(&self, elapsed: Duration) -> f64
Get pages per second.
Sourcepub fn avg_fetch_time_ms(&self) -> f64
pub fn avg_fetch_time_ms(&self) -> f64
Get average fetch time in milliseconds.
Sourcepub fn avg_analysis_time_ms(&self) -> f64
pub fn avg_analysis_time_ms(&self) -> f64
Get average analysis time in milliseconds.
Sourcepub fn throughput_bps(&self, elapsed: Duration) -> f64
pub fn throughput_bps(&self, elapsed: Duration) -> f64
Get total throughput (bytes per second).
Sourcepub fn snapshot(&self) -> MetricsSnapshot
pub fn snapshot(&self) -> MetricsSnapshot
Get snapshot of all metrics.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Metrics
impl RefUnwindSafe for Metrics
impl Send for Metrics
impl Sync for Metrics
impl Unpin for Metrics
impl UnsafeUnpin for Metrics
impl UnwindSafe for Metrics
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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>
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