mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-06-18 15:28:12 +00:00
To not log stats handing NotFound error if allow_unknown_gateways.
In this case it is expected that (some) gateways can't be found in the database.
This commit is contained in:
@ -8,7 +8,7 @@ use chrono::{DateTime, Local};
|
|||||||
use tracing::{error, info, span, trace, Instrument, Level};
|
use tracing::{error, info, span, trace, Instrument, Level};
|
||||||
|
|
||||||
use crate::gateway::backend as gateway_backend;
|
use crate::gateway::backend as gateway_backend;
|
||||||
use crate::storage::{gateway, metrics};
|
use crate::storage::{error::Error, gateway, metrics};
|
||||||
use crate::{config, region};
|
use crate::{config, region};
|
||||||
use chirpstack_api::{common, gw};
|
use chirpstack_api::{common, gw};
|
||||||
use lrwn::EUI64;
|
use lrwn::EUI64;
|
||||||
@ -36,9 +36,22 @@ impl Stats {
|
|||||||
let span = span!(Level::INFO, "stats", gateway_id = %gateway_id);
|
let span = span!(Level::INFO, "stats", gateway_id = %gateway_id);
|
||||||
|
|
||||||
if let Err(e) = Stats::_handle(gateway_id, s).instrument(span).await {
|
if let Err(e) = Stats::_handle(gateway_id, s).instrument(span).await {
|
||||||
|
match e.downcast_ref::<Error>() {
|
||||||
|
Some(Error::NotFound(_)) => {
|
||||||
|
// Only log an error in case allow_unknown_gateways is not set. Else it is
|
||||||
|
// expected that we will see NotFound errors as the gateway might not exist in
|
||||||
|
// the database.
|
||||||
|
let conf = config::get();
|
||||||
|
if !conf.gateway.allow_unknown_gateways {
|
||||||
error!(error = %e, "Handle gateway stats error");
|
error!(error = %e, "Handle gateway stats error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some(_) | None => {
|
||||||
|
error!(error = %e, "Handle gateway stats error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async fn _handle(gateway_id: EUI64, s: gw::GatewayStats) -> Result<()> {
|
async fn _handle(gateway_id: EUI64, s: gw::GatewayStats) -> Result<()> {
|
||||||
let mut ctx = Stats {
|
let mut ctx = Stats {
|
||||||
|
Reference in New Issue
Block a user