Module span

Module span 

Source
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

  1. Creation: Spans are created with a name and optional attributes
  2. Entry: Spans are entered to make them the current active span
  3. Events: Events and attributes can be added to active spans
  4. Exit: Spans are exited when no longer active
  5. 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§

CurrentSpan
Utilities for working with the currently active span.
PhantomNotSend 🔒
Technically, SpanGuard can implement both Send and Sync safely. It doesn’t, because it has a PhantomNotSend field, specifically added in order to make it !Send.
Span
A distributed tracing span representing a unit of work.
SpanGuard
Exits and drops the span when this is dropped.
SpanGuardInner 🔒
SpanGuardRef
Exits the span when dropped.
SpanGuardRefInner 🔒

Constants§

CURRENT_SPAN 🔒
PhantomNotSend 🔒