More logging

This commit is contained in:
Anna Khanova
2024-04-17 12:48:55 +02:00
parent e0a266942c
commit 33d1041d58
2 changed files with 14 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ use redis::{
};
use serde::Deserialize;
use tokio::sync::Mutex;
use tracing::info;
use crate::{
config::EndpointCacheConfig,
@@ -71,7 +72,9 @@ impl EndpointsCache {
}
// If cache is disabled, just collect the metrics and return.
if self.config.disable_cache {
ctx.set_rejected(self.should_reject(endpoint));
let rejected = self.should_reject(endpoint);
ctx.set_rejected(rejected);
info!(?rejected);
return true;
}
// If the limiter allows, we don't need to check the cache.
@@ -79,6 +82,7 @@ impl EndpointsCache {
return true;
}
let rejected = self.should_reject(endpoint);
info!(?rejected);
ctx.set_rejected(rejected);
!rejected
}

View File

@@ -5,7 +5,7 @@ use once_cell::sync::OnceCell;
use smol_str::SmolStr;
use std::net::IpAddr;
use tokio::sync::mpsc;
use tracing::{field::display, info_span, Span};
use tracing::{field::display, info, info_span, Span};
use uuid::Uuid;
use crate::{
@@ -198,12 +198,19 @@ impl Drop for RequestMonitoring {
} else {
ConnectOutcome::Failed
};
let rejected = self.rejected;
let ep = self
.endpoint_id
.as_ref()
.map(|x| x.as_str())
.unwrap_or_default();
info!(?ep, ?outcome, ?rejected);
Metrics::get()
.proxy
.invalid_endpoints_total
.inc(InvalidEndpointsGroup {
protocol: self.protocol,
rejected: self.rejected.into(),
rejected: rejected.into(),
outcome,
});
if let Some(tx) = self.sender.take() {