pub struct CurrentSpan;Expand description
Utilities for working with the currently active span.
This struct provides static methods for interacting with the current span in the thread-local context. It allows adding events, links, and attributes to the currently active span without needing a direct reference to it.
§Examples
use veecle_telemetry::{CurrentSpan, span};
let span = span!("operation");
let _guard = span.entered();
// Add an event to the current span
CurrentSpan::add_event("milestone", &[]);Implementations§
Source§impl CurrentSpan
impl CurrentSpan
Sourcepub fn add_event(name: &'static str, attributes: &[KeyValue<'static>])
pub fn add_event(name: &'static str, attributes: &[KeyValue<'static>])
Adds an event to the current span.
Events represent point-in-time occurrences within a span’s lifetime.
§Arguments
name- The name of the eventattributes- Key-value attributes providing additional context
§Examples
use veecle_telemetry::{CurrentSpan, KeyValue, Value, span};
let _guard = span!("operation").entered();
CurrentSpan::add_event("checkpoint", &[]);
CurrentSpan::add_event("milestone", &[KeyValue::new("progress", 75)]);Sourcepub fn add_link(link: SpanContext)
pub fn add_link(link: SpanContext)
Creates a link from the current span to another span.
Links connect spans across different traces, allowing you to represent relationships between spans that are not parent-child relationships.
§Examples
use veecle_telemetry::{CurrentSpan, Span, SpanContext, SpanId, ProcessId};
let _guard = Span::new("my_span", &[]).entered();
let external_context = SpanContext::new(ProcessId::from_raw(0x123), SpanId(0x456));
CurrentSpan::add_link(external_context);Sourcepub fn set_attribute(attribute: KeyValue<'static>)
pub fn set_attribute(attribute: KeyValue<'static>)
Sets an attribute on the current span.
Attributes provide additional context about the work being performed in the span.
§Arguments
attribute- The key-value attribute to set
§Examples
use veecle_telemetry::{CurrentSpan, KeyValue, Value, span};
let _guard = span!("operation").entered();
CurrentSpan::set_attribute(KeyValue::new("user_id", 123));
CurrentSpan::set_attribute(KeyValue::new("status", "success"));Trait Implementations§
Source§impl Debug for CurrentSpan
impl Debug for CurrentSpan
Source§impl Default for CurrentSpan
impl Default for CurrentSpan
Source§fn default() -> CurrentSpan
fn default() -> CurrentSpan
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for CurrentSpan
impl RefUnwindSafe for CurrentSpan
impl Send for CurrentSpan
impl Sync for CurrentSpan
impl Unpin for CurrentSpan
impl UnwindSafe for CurrentSpan
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