pub struct StatCollector {Show 16 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_dropped: AtomicUsize,
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 request_times: Arc<DashMap<String, Duration>>,
pub parsing_times: Arc<DashMap<String, Duration>>,
/* private fields */
}Expand description
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_dropped: AtomicUsize§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§request_times: Arc<DashMap<String, Duration>>§parsing_times: Arc<DashMap<String, Duration>>Implementations§
Source§impl StatCollector
impl StatCollector
Sourcepub 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.
Sourcepub fn average_request_time(&self) -> Option<Duration>
pub fn average_request_time(&self) -> Option<Duration>
Calculates the average request time across all recorded requests.
Sourcepub fn fastest_request_time(&self) -> Option<Duration>
pub fn fastest_request_time(&self) -> Option<Duration>
Gets the fastest request time among all recorded requests.
Sourcepub fn slowest_request_time(&self) -> Option<Duration>
pub fn slowest_request_time(&self) -> Option<Duration>
Gets the slowest request time among all recorded requests.
Sourcepub fn request_time_count(&self) -> usize
pub fn request_time_count(&self) -> usize
Gets the total number of recorded request times.
Sourcepub 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.
Sourcepub 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.
Sourcepub fn record_parsing_time(&self, duration: Duration)
pub fn record_parsing_time(&self, duration: Duration)
Records the time taken for parsing a response.
Sourcepub fn average_parsing_time(&self) -> Option<Duration>
pub fn average_parsing_time(&self) -> Option<Duration>
Calculates the average parsing time across all recorded parses.
Sourcepub fn fastest_parsing_time(&self) -> Option<Duration>
pub fn fastest_parsing_time(&self) -> Option<Duration>
Gets the fastest parsing time among all recorded parses.
Sourcepub fn slowest_parsing_time(&self) -> Option<Duration>
pub fn slowest_parsing_time(&self) -> Option<Duration>
Gets the slowest parsing time among all recorded parses.
Sourcepub fn parsing_time_count(&self) -> usize
pub fn parsing_time_count(&self) -> usize
Gets the total number of recorded parsing times.
Sourcepub fn clear_request_times(&self)
pub fn clear_request_times(&self)
Clears all recorded request times.
Sourcepub fn to_json_string(&self) -> Result<String, SpiderError>
pub fn to_json_string(&self) -> Result<String, SpiderError>
Converts the snapshot into a JSON string.
Sourcepub 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.
Sourcepub fn to_markdown_string(&self) -> String
pub fn to_markdown_string(&self) -> String
Exports the current statistics to a Markdown formatted string.
Trait Implementations§
Source§impl Debug for StatCollector
impl Debug for StatCollector
Source§impl Default for StatCollector
impl Default for StatCollector
Source§fn default() -> StatCollector
fn default() -> StatCollector
Source§impl Display for StatCollector
impl Display for StatCollector
Source§impl Serialize for StatCollector
impl Serialize for StatCollector
Source§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 UnsafeUnpin 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
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> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.