diff --git a/src/error.rs b/src/error.rs index fb1446c6..4cefc516 100644 --- a/src/error.rs +++ b/src/error.rs @@ -133,6 +133,8 @@ impl HandlerErrorKind { pub fn metric_label(&self) -> Option<&'static str> { match self { HandlerErrorKind::InvalidUA => Some("request.error.invalid_ua"), + // HandlerErrorKind::Reqest(e) if e.is_timeout() || e.is_connect()) + // metrics emitted elsewhere (in handlers::get_tiles) _ => None, } } @@ -140,6 +142,7 @@ impl HandlerErrorKind { /// Whether this error should trigger a Sentry event pub fn is_sentry_event(&self) -> bool { !matches!(self, HandlerErrorKind::InvalidUA) + && !matches!(self, HandlerErrorKind::Reqwest(e) if e.is_timeout() || e.is_connect()) } pub fn as_response_string(&self) -> String { diff --git a/src/web/handlers.rs b/src/web/handlers.rs index f1bbabc6..1d73b718 100644 --- a/src/web/handlers.rs +++ b/src/web/handlers.rs @@ -159,8 +159,6 @@ pub async fn get_tiles( Ok(tiles.to_response(settings.cache_control_header)) } Err(e) => { - metrics.incr_with_tags("tiles.get.error", Some(&tags)); - if matches!(e.kind(), HandlerErrorKind::BadAdmResponse(_)) { // Handle a bad response from ADM specially. // Report it to metrics and sentry, but also store an empty record @@ -185,6 +183,16 @@ pub async fn get_tiles( return Ok(HttpResponse::NoContent().finish()); } + match e.kind() { + HandlerErrorKind::Reqwest(e) if e.is_timeout() => tags.add_tag("reason", "timeout"), + HandlerErrorKind::Reqwest(e) if e.is_connect() => tags.add_tag("reason", "connect"), + _ => (), + } + if handle.fallback_tiles.is_some() { + tags.add_tag("fallback", "true"); + } + metrics.incr_with_tags("tiles.get.error", Some(&tags)); + // A general error occurred, try rendering fallback Tiles if let Some(tiles) = handle.fallback_tiles { return Ok(fallback_response(settings, &tiles));