Skip to content

Commit

Permalink
feat: log domain on end conn (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiroaisen authored Nov 14, 2023
2 parents 8fc0161 + ba36f38 commit 9a380b9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rs/packages/stream/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ impl StreamHandler {
ip,
station_id: station_id.clone(),
station_name: station_name.clone(),
domain: conn_doc_lite.domain,
account_id: station.account_id.clone(),
transfer_bytes: transfer_bytes.clone(),
token: drop_tracer.token(),
Expand Down Expand Up @@ -608,6 +609,7 @@ struct StreamConnectionDropper(Option<StreamConnectionDropperInner>);
struct StreamConnectionDropperInner {
id: String,
ip: IpAddr,
domain: Option<String>,
station_name: String,
station_id: String,
account_id: String,
Expand Down Expand Up @@ -655,6 +657,7 @@ impl Drop for StreamConnectionDropper {
ip,
station_name,
station_id,
domain,
account_id,
transfer_bytes,
start_time,
Expand All @@ -669,11 +672,11 @@ impl Drop for StreamConnectionDropper {
let duration_ms = start_time.elapsed().unwrap().as_millis() as u64;
let now = DateTime::now();


{
let domain = domain.as_deref().unwrap_or("???");
let s = duration_ms as f64 / 1_000.0;
let end_reason = end_reason.lock();
info!("END conn {id} {ip} - station: {station_id} ({station_name}) | reason={end_reason} - {s} s");
info!("END conn {id} {ip} - station: {station_id} ({station_name}) in {domain} | reason={end_reason} - {s} s");
}

tokio::spawn(async move {
Expand Down

0 comments on commit 9a380b9

Please sign in to comment.