pub struct TracingField { /* private fields */ }Expand description
Unified tracing metadata for a context key.
Controls two behaviors:
- Extract: populate a context variable from a tracing span field
- Enrich: include the context value in log output
Created via TracingFieldBuilder:
ⓘ
use dcontext_tracing::TracingField;
builder.register_with::<String>("request_id", |opts| {
opts.cached().with_metadata(
TracingField::builder("rid")
.extract_from_str(|s| Some(s.to_string()))
.enrich_display::<String>()
.build()
)
});Implementations§
Source§impl TracingField
impl TracingField
Sourcepub fn builder(log_name: &'static str) -> TracingFieldBuilder
pub fn builder(log_name: &'static str) -> TracingFieldBuilder
Start building a TracingField with the given log field name.
The log_name is the field name used in log output (enrichment direction).
It can differ from the context key.
Sourcepub fn span_field(&self) -> Option<&'static str>
pub fn span_field(&self) -> Option<&'static str>
The span field name to extract from, if extraction is enabled.
Sourcepub fn has_extract(&self) -> bool
pub fn has_extract(&self) -> bool
Whether this field has extraction enabled.
Sourcepub fn has_enrich(&self) -> bool
pub fn has_enrich(&self) -> bool
Whether this field has enrichment enabled.
Auto Trait Implementations§
impl Freeze for TracingField
impl !RefUnwindSafe for TracingField
impl Send for TracingField
impl Sync for TracingField
impl Unpin for TracingField
impl UnsafeUnpin for TracingField
impl !UnwindSafe for TracingField
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