diff --git a/iot_config/src/gateway_service.rs b/iot_config/src/gateway_service.rs index b74bf1cee..7b3b794dc 100644 --- a/iot_config/src/gateway_service.rs +++ b/iot_config/src/gateway_service.rs @@ -184,7 +184,7 @@ impl iot_config::Gateway for GatewayService { })?; let (region, gain) = match self.resolve_gateway_info(address).await { - Err(_) => { + Err(status) if status.code() == tonic::Code::NotFound => { tracing::debug!( pubkey = %address, %default_region, @@ -192,6 +192,15 @@ impl iot_config::Gateway for GatewayService { ); (default_region, 0) } + Err(status) => { + tracing::error!( + pubkey = %address, + %default_region, + "gateway lookup failed" + ); + telemetry::count_region_lookup(default_region, None); + return Err(Status::internal(status.message().to_string())); + } Ok(GatewayInfo { metadata, .. }) => match metadata { None => { tracing::debug!( @@ -204,7 +213,7 @@ impl iot_config::Gateway for GatewayService { Some(metadata) => (metadata.region, metadata.gain), }, }; - telemetry::count_region_lookup(default_region, region); + telemetry::count_region_lookup(default_region, Some(region)); let params = self.region_map.get_params(®ion); diff --git a/iot_config/src/telemetry.rs b/iot_config/src/telemetry.rs index 8dd95a1ff..883c91f73 100644 --- a/iot_config/src/telemetry.rs +++ b/iot_config/src/telemetry.rs @@ -31,13 +31,15 @@ pub fn gauge_hexes(cells: usize) { pub fn count_region_lookup( default_region: helium_proto::Region, - reported_region: helium_proto::Region, + reported_region: Option, ) { + let reported_region = + reported_region.map_or_else(|| "LOOKUP_FAILED".to_string(), |region| region.to_string()); metrics::increment_counter!( REGION_LOOKUP_METRIC, // per metrics docs, &str should be preferred for performance; should the regions be // mapped through a match of region => &'static str of the name? - "default_region" => default_region.to_string(), "reported_region" => reported_region.to_string() + "default_region" => default_region.to_string(), "reported_region" => reported_region ); }