Struct CurrentSpan

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§

§

impl CurrentSpan

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 event
  • attributes - 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)]);

Does nothing if there’s no active span.

Creates a link from the current span to another span. Does nothing if there’s no active 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, TraceId};

let _guard = Span::new("my_span", &[]).entered();

let external_context = SpanContext::new(TraceId(0x123), SpanId(0x456));
CurrentSpan::add_link(external_context);

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"));

Does nothing if there’s no active span.

Trait Implementations§

§

impl Debug for CurrentSpan

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Default for CurrentSpan

§

fn default() -> CurrentSpan

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V