Expand description
Distributed tracing spans for tracking units of work.
This module provides the core span implementation for distributed tracing. Spans represent units of work within a trace and can be nested to show relationships between different operations.
§Key Concepts
- Span: A unit of work within a trace, with a name and optional attributes
- Span Context: The trace and span IDs that identify a span within a trace
- Span Guards: RAII guards that automatically handle span entry/exit
- Current Span: Thread-local tracking of the currently active span
§Basic Usage
use veecle_telemetry::{CurrentSpan, span};
// Create and enter a span
let span = span!("operation", user_id = 123);
let _guard = span.entered();
// Add events to the current span
CurrentSpan::add_event("checkpoint", &[]);
// Span is automatically exited when guard is dropped§Span Lifecycle
- Creation: Spans are created with a name and optional attributes
- Entry: Spans are entered to make them the current active span
- Events: Events and attributes can be added to active spans
- Exit: Spans are exited when no longer active
- Close: Spans are closed when their work is complete
§Nesting
Spans can be nested to show relationships:
use veecle_telemetry::span;
let parent = span!("parent_operation");
let _parent_guard = parent.entered();
// This span will automatically be a child of the parent
let child = span!("child_operation");
let _child_guard = child.entered();Structs§
- Current
Span - Utilities for working with the currently active span.
- Phantom
NotSend 🔒 - Technically,
SpanGuardcan implement bothSendandSyncsafely. It doesn’t, because it has aPhantomNotSendfield, specifically added in order to make it!Send. - Span
- A distributed tracing span representing a unit of work.
- Span
Guard - Exits and drops the span when this is dropped.
- Span
Guard 🔒Inner - Span
Guard Ref - Exits the span when dropped.
- Span
Guard 🔒RefInner