pub struct Context {
pub trace_id: Option<String>,
pub span_id: Option<String>,
pub request_id: Option<String>,
pub user_id: Option<String>,
pub tenant_id: Option<String>,
}Expand description
Context fields that are propagated through log events.
Fields§
§trace_id: Option<String>OpenTelemetry trace ID
span_id: Option<String>OpenTelemetry span ID
request_id: Option<String>HTTP request identifier
user_id: Option<String>Authenticated user identifier
tenant_id: Option<String>Multi-tenant organization identifier
Implementations§
Source§impl Context
impl Context
Sourcepub fn generate_request_id() -> String
pub fn generate_request_id() -> String
Generate a new request ID.
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 the trace ID.
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 the span ID.
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 the request ID.
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 the user ID.
Sourcepub fn with_tenant_id(self, tenant_id: impl Into<String>) -> Self
pub fn with_tenant_id(self, tenant_id: impl Into<String>) -> Self
Set the tenant ID.
Sourcepub fn from_span() -> Self
pub fn from_span() -> Self
Extract context from the current tracing span.
Note: This is a simplified implementation. For full OpenTelemetry support,
use the otel module’s extract_context_from_otel() function.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Context
impl<'de> Deserialize<'de> for Context
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 Context
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
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