pub struct RequestRecord {
pub method: String,
pub path: String,
pub status: u16,
pub duration: Duration,
pub timestamp: DateTime<Utc>,
pub client_id: Option<String>,
pub response_size: Option<u64>,
pub authenticated: bool,
pub tags: HashMap<String, String>,
}Expand description
Record of a single request for analytics
Fields§
§method: StringHTTP method
path: StringRequest path (normalized)
status: u16HTTP status code
duration: DurationRequest duration
timestamp: DateTime<Utc>Request timestamp
client_id: Option<String>Client identifier (IP, user ID, etc.)
response_size: Option<u64>Response body size in bytes
authenticated: boolWhether the request was authenticated
Custom tags for filtering
Implementations§
Source§impl RequestRecord
impl RequestRecord
Sourcepub fn new(
method: impl Into<String>,
path: impl Into<String>,
status: u16,
duration: Duration,
) -> Self
pub fn new( method: impl Into<String>, path: impl Into<String>, status: u16, duration: Duration, ) -> Self
Create a new request record
pub fn with_client_id(self, client_id: impl Into<String>) -> Self
pub fn with_response_size(self, size: u64) -> Self
pub fn with_authenticated(self, authenticated: bool) -> Self
pub fn with_tag(self, key: impl Into<String>, value: impl Into<String>) -> Self
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Check if request was successful (2xx)
Sourcepub fn is_client_error(&self) -> bool
pub fn is_client_error(&self) -> bool
Check if request was a client error (4xx)
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Check if request was a server error (5xx)
Trait Implementations§
Source§impl Clone for RequestRecord
impl Clone for RequestRecord
Source§fn clone(&self) -> RequestRecord
fn clone(&self) -> RequestRecord
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RequestRecord
impl RefUnwindSafe for RequestRecord
impl Send for RequestRecord
impl Sync for RequestRecord
impl Unpin for RequestRecord
impl UnwindSafe for RequestRecord
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more