From faf15ec2e71e213723f3ce44cd3486cae43e04cd Mon Sep 17 00:00:00 2001 From: Eric Kidd Date: Wed, 29 Jun 2022 06:49:59 -0400 Subject: [PATCH] Trace rate limiting delays --- src/geocoders/smarty/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/geocoders/smarty/mod.rs b/src/geocoders/smarty/mod.rs index 7f6f57a..9d8f18f 100644 --- a/src/geocoders/smarty/mod.rs +++ b/src/geocoders/smarty/mod.rs @@ -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}; @@ -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