pub struct InFlightRequestsCounter { /* private fields */ }
Available on crate feature
metrics
only.Expand description
An atomic counter that keeps track of the number of in-flight requests.
This will normally combined with InFlightRequestsLayer
or InFlightRequests
which will
update the counter as requests arrive.
Implementations§
source§impl InFlightRequestsCounter
impl InFlightRequestsCounter
sourcepub async fn run_emitter<F, Fut>(self, interval: Duration, emit: F)
pub async fn run_emitter<F, Fut>(self, interval: Duration, emit: F)
Run a future every interval
which receives the current number of in-flight requests.
This can be used to send the current count to your metrics system.
This function will loop forever so normally it is called with [tokio::spawn
]:
use tower_http::metrics::in_flight_requests::InFlightRequestsCounter;
use std::time::Duration;
let counter = InFlightRequestsCounter::new();
tokio::spawn(
counter.run_emitter(Duration::from_secs(10), |count: usize| async move {
// Send `count` to metrics system.
}),
);
Trait Implementations§
source§impl Clone for InFlightRequestsCounter
impl Clone for InFlightRequestsCounter
source§fn clone(&self) -> InFlightRequestsCounter
fn clone(&self) -> InFlightRequestsCounter
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for InFlightRequestsCounter
impl Debug for InFlightRequestsCounter
source§impl Default for InFlightRequestsCounter
impl Default for InFlightRequestsCounter
source§fn default() -> InFlightRequestsCounter
fn default() -> InFlightRequestsCounter
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl RefUnwindSafe for InFlightRequestsCounter
impl Send for InFlightRequestsCounter
impl Sync for InFlightRequestsCounter
impl Unpin for InFlightRequestsCounter
impl UnwindSafe for InFlightRequestsCounter
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
Mutably borrows from an owned value. Read more