Skip to main content

StatCollector

Struct StatCollector 

Source
pub struct StatCollector {
Show 16 fields pub start_time: Instant, pub requests_enqueued: Atomic<usize>, pub requests_sent: Atomic<usize>, pub requests_succeeded: Atomic<usize>, pub requests_failed: Atomic<usize>, pub requests_retried: Atomic<usize>, pub requests_dropped: Atomic<usize>, pub responses_received: Atomic<usize>, pub responses_from_cache: Atomic<usize>, pub response_status_counts: Arc<DashMap<u16, usize>>, pub total_bytes_downloaded: Atomic<usize>, pub items_scraped: Atomic<usize>, pub items_processed: Atomic<usize>, pub items_dropped_by_pipeline: Atomic<usize>, pub request_times: Cache<String, Duration>, pub parsing_times: Cache<String, Duration>, /* private fields */
}
Expand description

Collects and stores various statistics about the crawler’s operation.

Fields§

§start_time: Instant§requests_enqueued: Atomic<usize>§requests_sent: Atomic<usize>§requests_succeeded: Atomic<usize>§requests_failed: Atomic<usize>§requests_retried: Atomic<usize>§requests_dropped: Atomic<usize>§responses_received: Atomic<usize>§responses_from_cache: Atomic<usize>§response_status_counts: Arc<DashMap<u16, usize>>§total_bytes_downloaded: Atomic<usize>§items_scraped: Atomic<usize>§items_processed: Atomic<usize>§items_dropped_by_pipeline: Atomic<usize>§request_times: Cache<String, Duration>§parsing_times: Cache<String, Duration>

Implementations§

Source§

impl StatCollector

Source

pub fn record_request_time(&self, url: &str, duration: Duration)

Records the time taken for a request.

Source

pub fn average_request_time(&self) -> Option<Duration>

Calculates the average request time across all recorded requests.

Source

pub fn fastest_request_time(&self) -> Option<Duration>

Gets the fastest request time among all recorded requests.

Source

pub fn slowest_request_time(&self) -> Option<Duration>

Gets the slowest request time among all recorded requests.

Source

pub fn request_time_count(&self) -> usize

Gets the total number of recorded request times.

Source

pub fn get_request_time(&self, url: &str) -> Option<Duration>

Gets the request time for a specific URL.

Source

pub fn get_all_request_times(&self) -> Vec<(String, Duration)>

Gets all recorded request times as a vector of (URL, Duration) pairs.

Source

pub fn record_parsing_time(&self, duration: Duration)

Records the time taken for parsing a response.

Source

pub fn average_parsing_time(&self) -> Option<Duration>

Calculates the average parsing time across all recorded parses.

Source

pub fn fastest_parsing_time(&self) -> Option<Duration>

Gets the fastest parsing time among all recorded parses.

Source

pub fn slowest_parsing_time(&self) -> Option<Duration>

Gets the slowest parsing time among all recorded parses.

Source

pub fn parsing_time_count(&self) -> usize

Gets the total number of recorded parsing times.

Source

pub fn clear_request_times(&self)

Clears all recorded request times.

Source

pub fn clear_parsing_times(&self)

Clears all recorded parsing times.

Source

pub fn to_json_string(&self) -> Result<String, SpiderError>

Converts the snapshot into a JSON string.

Source

pub fn to_json_string_pretty(&self) -> Result<String, SpiderError>

Converts the snapshot into a pretty-printed JSON string.

Source

pub fn to_markdown_string(&self) -> String

Exports the current statistics to a Markdown formatted string.

Source

pub fn to_live_report_string(&self) -> String

Exports current statistics to the text layout used for terminal output.

Trait Implementations§

Source§

impl Debug for StatCollector

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for StatCollector

Source§

fn default() -> StatCollector

Returns the “default value” for a type. Read more
Source§

impl Display for StatCollector

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Serialize for StatCollector

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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