Struct StatCollector
pub struct StatCollector {Show 20 fields
pub start_time: Instant,
pub requests_enqueued: AtomicUsize,
pub requests_sent: AtomicUsize,
pub requests_succeeded: AtomicUsize,
pub requests_failed: AtomicUsize,
pub requests_retried: AtomicUsize,
pub requests_scheduled_for_retry: AtomicUsize,
pub requests_dropped: AtomicUsize,
pub retry_delay_in_flight_ms: AtomicU64,
pub responses_received: AtomicUsize,
pub responses_from_cache: AtomicUsize,
pub response_status_counts: Arc<DashMap<u16, usize>>,
pub total_bytes_downloaded: AtomicUsize,
pub items_scraped: AtomicUsize,
pub items_processed: AtomicUsize,
pub items_dropped_by_pipeline: AtomicUsize,
pub queue_depth: AtomicUsize,
pub parser_backlog: AtomicUsize,
pub pipeline_backlog: AtomicUsize,
pub retry_backlog: AtomicUsize,
/* private fields */
}Expand description
Core runtime types and traits used to define and run a crawl. Collects and stores various statistics about the crawler’s operation.
Fields§
§start_time: Instant§requests_enqueued: AtomicUsize§requests_sent: AtomicUsize§requests_succeeded: AtomicUsize§requests_failed: AtomicUsize§requests_retried: AtomicUsize§requests_scheduled_for_retry: AtomicUsize§requests_dropped: AtomicUsize§retry_delay_in_flight_ms: AtomicU64§responses_received: AtomicUsize§responses_from_cache: AtomicUsize§response_status_counts: Arc<DashMap<u16, usize>>§total_bytes_downloaded: AtomicUsize§items_scraped: AtomicUsize§items_processed: AtomicUsize§items_dropped_by_pipeline: AtomicUsize§queue_depth: AtomicUsize§parser_backlog: AtomicUsize§pipeline_backlog: AtomicUsize§retry_backlog: AtomicUsizeImplementations§
§impl StatCollector
impl StatCollector
pub fn snapshot(&self) -> MetricsSnapshot
pub fn snapshot(&self) -> MetricsSnapshot
Returns a public immutable snapshot of the current crawl metrics.
pub fn record_request_time(&self, _url: &str, duration: Duration)
pub fn record_request_time(&self, _url: &str, duration: Duration)
Records the time taken for a request.
pub fn average_request_time(&self) -> Option<Duration>
pub fn average_request_time(&self) -> Option<Duration>
Calculates the average request time across all recorded requests.
pub fn fastest_request_time(&self) -> Option<Duration>
pub fn fastest_request_time(&self) -> Option<Duration>
Gets the fastest request time among all recorded requests.
pub fn slowest_request_time(&self) -> Option<Duration>
pub fn slowest_request_time(&self) -> Option<Duration>
Gets the slowest request time among all recorded requests.
pub fn request_time_count(&self) -> usize
pub fn request_time_count(&self) -> usize
Gets the total number of recorded request times.
pub fn get_request_time(&self, url: &str) -> Option<Duration>
pub fn get_request_time(&self, url: &str) -> Option<Duration>
Gets the request time for a specific URL.
pub fn get_all_request_times(&self) -> Vec<(String, Duration)>
pub fn get_all_request_times(&self) -> Vec<(String, Duration)>
Gets all recorded request times as a vector of (URL, Duration) pairs.
pub fn record_parsing_time(&self, duration: Duration)
pub fn record_parsing_time(&self, duration: Duration)
Records the time taken for parsing a response.
pub fn average_parsing_time(&self) -> Option<Duration>
pub fn average_parsing_time(&self) -> Option<Duration>
Calculates the average parsing time across all recorded parses.
pub fn fastest_parsing_time(&self) -> Option<Duration>
pub fn fastest_parsing_time(&self) -> Option<Duration>
Gets the fastest parsing time among all recorded parses.
pub fn slowest_parsing_time(&self) -> Option<Duration>
pub fn slowest_parsing_time(&self) -> Option<Duration>
Gets the slowest parsing time among all recorded parses.
pub fn parsing_time_count(&self) -> usize
pub fn parsing_time_count(&self) -> usize
Gets the total number of recorded parsing times.
pub fn clear_request_times(&self)
pub fn clear_request_times(&self)
Clears all recorded request times.
pub fn clear_parsing_times(&self)
pub fn clear_parsing_times(&self)
Clears all recorded parsing times.
pub fn to_json_string(&self) -> Result<String, SpiderError>
pub fn to_json_string(&self) -> Result<String, SpiderError>
Converts the snapshot into a JSON string.
pub fn to_json_string_pretty(&self) -> Result<String, SpiderError>
pub fn to_json_string_pretty(&self) -> Result<String, SpiderError>
Converts the snapshot into a pretty-printed JSON string.
pub fn to_markdown_string(&self) -> String
pub fn to_markdown_string(&self) -> String
Exports the current statistics to a Markdown formatted string.
pub fn to_live_report_string(&self) -> String
pub fn to_live_report_string(&self) -> String
Exports current statistics to the text layout used for terminal output.
Trait Implementations§
§impl Debug for StatCollector
impl Debug for StatCollector
§impl Default for StatCollector
impl Default for StatCollector
§fn default() -> StatCollector
fn default() -> StatCollector
§impl Display for StatCollector
impl Display for StatCollector
§impl Serialize for StatCollector
impl Serialize for StatCollector
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl !Freeze for StatCollector
impl !RefUnwindSafe for StatCollector
impl Send for StatCollector
impl Sync for StatCollector
impl Unpin for StatCollector
impl !UnwindSafe for StatCollector
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<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>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.