pub struct CorrelationContext {
pub correlation_id: CorrelationId,
pub parent_id: Option<CorrelationId>,
pub operation: String,
pub service: String,
pub user_id: Option<String>,
pub session_id: Option<String>,
pub request_id: Option<String>,
pub trace_id: Option<String>,
pub span_id: Option<String>,
pub attributes: HashMap<String, String>,
pub created_at: DateTime<Utc>,
}Expand description
Context for tracking correlated operations
Fields§
§correlation_id: CorrelationId§parent_id: Option<CorrelationId>§operation: String§service: String§user_id: Option<String>§session_id: Option<String>§request_id: Option<String>§trace_id: Option<String>§span_id: Option<String>§attributes: HashMap<String, String>§created_at: DateTime<Utc>Implementations§
Source§impl CorrelationContext
impl CorrelationContext
Sourcepub fn new(operation: impl Into<String>, service: impl Into<String>) -> Self
pub fn new(operation: impl Into<String>, service: impl Into<String>) -> Self
Create a new correlation context
Sourcepub fn create_child(&self, operation: impl Into<String>) -> Self
pub fn create_child(&self, operation: impl Into<String>) -> Self
Create a child context with a new correlation ID but linked parent
Sourcepub fn with_user_id(self, user_id: impl Into<String>) -> Self
pub fn with_user_id(self, user_id: impl Into<String>) -> Self
Set user ID for this context
Sourcepub fn with_session_id(self, session_id: impl Into<String>) -> Self
pub fn with_session_id(self, session_id: impl Into<String>) -> Self
Set session ID for this context
Sourcepub fn with_request_id(self, request_id: impl Into<String>) -> Self
pub fn with_request_id(self, request_id: impl Into<String>) -> Self
Set request ID for this context
Sourcepub fn with_trace_id(self, trace_id: impl Into<String>) -> Self
pub fn with_trace_id(self, trace_id: impl Into<String>) -> Self
Set trace ID for this context
Sourcepub fn with_span_id(self, span_id: impl Into<String>) -> Self
pub fn with_span_id(self, span_id: impl Into<String>) -> Self
Set span ID for this context
Sourcepub fn with_attribute(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_attribute( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add an attribute to this context
Sourcepub fn get_attribute(&self, key: &str) -> Option<&String>
pub fn get_attribute(&self, key: &str) -> Option<&String>
Get an attribute from this context
Trait Implementations§
Source§impl Clone for CorrelationContext
impl Clone for CorrelationContext
Source§fn clone(&self) -> CorrelationContext
fn clone(&self) -> CorrelationContext
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 moreSource§impl Debug for CorrelationContext
impl Debug for CorrelationContext
Source§impl<'de> Deserialize<'de> for CorrelationContext
impl<'de> Deserialize<'de> for CorrelationContext
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CorrelationContext
impl RefUnwindSafe for CorrelationContext
impl Send for CorrelationContext
impl Sync for CorrelationContext
impl Unpin for CorrelationContext
impl UnwindSafe for CorrelationContext
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