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 Freeze for InFlightRequestsCounter
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