pub struct CorrelationContext { /* private fields */ }Expand description
Stable, low-cardinality correlation fields for logs, spans, and metrics.
Implementations§
Source§impl CorrelationContext
impl CorrelationContext
Sourcepub fn from_http_headers(
service: Option<&str>,
method: impl Into<String>,
route: Option<&str>,
headers: &HeaderMap,
) -> Self
pub fn from_http_headers( service: Option<&str>, method: impl Into<String>, route: Option<&str>, headers: &HeaderMap, ) -> Self
Builds HTTP correlation from headers and a route pattern.
route must be a framework route pattern such as /users/:id; raw
paths are intentionally not accepted to avoid high-cardinality logs.
Sourcepub fn from_rpc_metadata(
service: impl Into<String>,
method: impl Into<String>,
metadata: &MetadataMap,
) -> Self
pub fn from_rpc_metadata( service: impl Into<String>, method: impl Into<String>, metadata: &MetadataMap, ) -> Self
Builds gRPC correlation from tonic metadata and an RPC method pattern.
Sourcepub fn from_rpc_parts(
service: impl Into<String>,
method: impl Into<String>,
request_id: Option<&str>,
traceparent: Option<&str>,
) -> Self
pub fn from_rpc_parts( service: impl Into<String>, method: impl Into<String>, request_id: Option<&str>, traceparent: Option<&str>, ) -> Self
Builds correlation from explicit RPC request and trace context.
Sourcepub fn new(
service: impl Into<String>,
transport: &'static str,
route: impl Into<String>,
method: impl Into<String>,
) -> Self
pub fn new( service: impl Into<String>, transport: &'static str, route: impl Into<String>, method: impl Into<String>, ) -> Self
Creates a low-cardinality context from explicit parts.
Sourcepub fn with_status(self, status: impl Into<String>) -> Self
pub fn with_status(self, status: impl Into<String>) -> Self
Sets status or code.
Sourcepub fn traceparent(&self) -> Option<&str>
pub fn traceparent(&self) -> Option<&str>
Returns the traceparent value when one is available.
Sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
Returns the request id when one is available.
Sourcepub fn into_log_fields(self) -> LogFields
pub fn into_log_fields(self) -> LogFields
Converts the context into stable logging fields.
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 (const: unstable) · 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 PartialEq for CorrelationContext
impl PartialEq for CorrelationContext
Source§fn eq(&self, other: &CorrelationContext) -> bool
fn eq(&self, other: &CorrelationContext) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for CorrelationContext
impl StructuralPartialEq for CorrelationContext
Auto Trait Implementations§
impl Freeze for CorrelationContext
impl RefUnwindSafe for CorrelationContext
impl Send for CorrelationContext
impl Sync for CorrelationContext
impl Unpin for CorrelationContext
impl UnsafeUnpin 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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request