pub struct RequestContext {
pub request_id: String,
pub client_id: String,
pub started_at: Instant,
pub path: String,
pub method: String,
}Expand description
Per-request context injected by middleware at the entry point.
Carries metadata needed for logging, tracing, and metrics throughout the request lifetime.
Fields§
§request_id: StringUnique request identifier (e.g. "oxibonsai-1714000000000-1").
client_id: StringCaller identity — typically an IP address or API key prefix.
started_at: InstantWall-clock instant when the request was received.
path: StringRequest path (e.g. "/v1/chat/completions").
method: StringHTTP method in upper-case (e.g. "POST").
Implementations§
Source§impl RequestContext
impl RequestContext
Sourcepub fn new(path: &str, method: &str, client_id: &str) -> Self
pub fn new(path: &str, method: &str, client_id: &str) -> Self
Create a new context with an auto-generated request ID.
Sourcepub fn with_id(
request_id: String,
path: &str,
method: &str,
client_id: &str,
) -> Self
pub fn with_id( request_id: String, path: &str, method: &str, client_id: &str, ) -> Self
Create a context with an explicit request ID (used with RequestIdGen).
Sourcepub fn elapsed_ms(&self) -> u64
pub fn elapsed_ms(&self) -> u64
Elapsed time since the request was received, in milliseconds.
Trait Implementations§
Source§impl Clone for RequestContext
impl Clone for RequestContext
Source§fn clone(&self) -> RequestContext
fn clone(&self) -> RequestContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 RequestContext
impl RefUnwindSafe for RequestContext
impl Send for RequestContext
impl Sync for RequestContext
impl Unpin for RequestContext
impl UnsafeUnpin for RequestContext
impl UnwindSafe for RequestContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more