Skip to content

Commit

Permalink
Trace rate limiting delays
Browse files Browse the repository at this point in the history
  • Loading branch information
emk committed Jun 29, 2022
1 parent 3ff51c8 commit faf15ec
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/geocoders/smarty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::sync::Arc;
use async_trait::async_trait;
use leaky_bucket::RateLimiter;
use metrics::{counter, describe_counter};
use tracing::{trace_span, Instrument};

use crate::{addresses::Address, Result};

Expand Down Expand Up @@ -87,7 +88,10 @@ impl Geocoder for Smarty {
// specified number of addresses. We only check if we have one, in order
// minimize thread synchronization costs.
if let Some(rate_limiter) = &self.rate_limiter {
rate_limiter.acquire(addresses.len()).await;
let permits_needed = addresses.len();
let span =
trace_span!("rate_limiter::acquire", permits_needed = permits_needed);
rate_limiter.acquire(permits_needed).instrument(span).await;
}

let requests = addresses
Expand Down

0 comments on commit faf15ec

Please sign in to comment.