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 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more