diff --git a/src/main.rs b/src/main.rs index 913cc84..89b10cb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -100,6 +100,8 @@ impl Fairing for MetricsState { let method = req.method().as_str(); let status = res.status().to_string(); let query = req.query_fields().map(|f| format!("{}={},", f.name, f.value)).collect::(); + let ip = req.client_ip().map_or_else(|| "N/A".to_string(), |ip| ip.to_string()); + let agent = req.headers().get_one("USER-AGENT").unwrap_or("N/A").to_owned(); self.counter.add( 1, &[ @@ -107,6 +109,8 @@ impl Fairing for MetricsState { KeyValue::new("Method", method), KeyValue::new("Status", status), KeyValue::new("Query", query), + KeyValue::new("IP", ip), + KeyValue::new("User-Agent", agent), ], ); } }