Module tracing

Module tracing 

Source
Expand description

OpenTelemetry tracing integration for distributed observability.

This module provides OpenTelemetry tracing capabilities for tracking operations across the CHIE protocol, enabling distributed tracing, performance analysis, and debugging in production environments.

§Features

  • Span Management: Create and manage tracing spans
  • Context Propagation: Propagate trace context across async boundaries
  • Attribute Recording: Record custom attributes and events
  • Multiple Exporters: Support for Jaeger, Zipkin, OTLP, and console
  • Sampling: Configurable sampling strategies
  • Performance: Low-overhead tracing with minimal impact

§Example

use chie_core::tracing::{TracingConfig, TracingManager, span_scope};
use std::time::Duration;

// Initialize tracing
let config = TracingConfig::default()
    .with_service_name("chie-node")
    .with_console_exporter(true);

let manager = TracingManager::new(config)?;

// Create a traced operation
{
    let _guard = span_scope("store_chunk");
    // Your operation here
    std::thread::sleep(Duration::from_millis(10));
}

// Shutdown to flush remaining spans
manager.shutdown()?;

Structs§

Span
Represents a tracing span for an operation.
SpanEvent
Represents an event within a span.
SpanGuard
RAII guard for automatic span finish.
TraceContext
Trace context for propagating trace information.
TracingConfig
Configuration for OpenTelemetry tracing.
TracingManager
Tracing manager for initializing and managing OpenTelemetry.
TracingStats
Statistics for tracing operations.

Enums§

TracingError
Errors that can occur during tracing operations.

Functions§

get_tracing_stats
Gets the global tracing statistics.
reset_tracing_stats
Resets the global tracing statistics.
span_scope
Creates a new span with automatic finish on drop.
span_with_attributes
Creates a span with attributes.