pub struct RequestInfo {
pub timestamp: DateTime<Utc>,
pub client_id: String,
pub method_name: String,
pub parameters: Value,
pub response_time_ms: Option<u64>,
pub success: bool,
pub error_message: Option<String>,
pub status_code: Option<u16>,
pub metadata: HashMap<String, Value>,
}Expand description
Contains analytics information for a single request, used for monitoring and debugging.
Fields§
§timestamp: DateTime<Utc>The timestamp when the request was received.
client_id: StringThe identifier of the client that made the request.
method_name: StringThe name of the tool or method that was called.
parameters: ValueThe parameters provided in the request, potentially sanitized for privacy.
response_time_ms: Option<u64>The total time taken to generate a response, in milliseconds.
success: boolA boolean indicating whether the request was successful.
error_message: Option<String>The error message, if the request failed.
status_code: Option<u16>The HTTP status code, if the request was handled over HTTP.
metadata: HashMap<String, Value>Additional custom metadata for analytics.
Implementations§
Source§impl RequestInfo
impl RequestInfo
Sourcepub fn new(client_id: String, method_name: String, parameters: Value) -> Self
pub fn new(client_id: String, method_name: String, parameters: Value) -> Self
Creates a new RequestInfo for analytics.
Sourcepub const fn complete_success(self, response_time_ms: u64) -> Self
pub const fn complete_success(self, response_time_ms: u64) -> Self
Marks the request as completed successfully and records the response time.
Sourcepub fn complete_error(self, response_time_ms: u64, error: String) -> Self
pub fn complete_error(self, response_time_ms: u64, error: String) -> Self
Marks the request as failed and records the response time and error message.
Sourcepub const fn with_status_code(self, code: u16) -> Self
pub const fn with_status_code(self, code: u16) -> Self
Sets the HTTP status code for this request.
Sourcepub fn with_metadata(self, key: String, value: Value) -> Self
pub fn with_metadata(self, key: String, value: Value) -> Self
Adds a key-value pair to the analytics metadata.
Trait Implementations§
Source§impl Clone for RequestInfo
impl Clone for RequestInfo
Source§fn clone(&self) -> RequestInfo
fn clone(&self) -> RequestInfo
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RequestInfo
impl Debug for RequestInfo
Source§impl<'de> Deserialize<'de> for RequestInfo
impl<'de> Deserialize<'de> for RequestInfo
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for RequestInfo
impl RefUnwindSafe for RequestInfo
impl Send for RequestInfo
impl Sync for RequestInfo
impl Unpin for RequestInfo
impl UnwindSafe for RequestInfo
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)