revoke-trace 0.3.0

Distributed tracing with OpenTelemetry for Revoke framework
Documentation
use revoke_trace::{
    init_tracer, shutdown_tracer, span::SpanBuilder, span::SpanKind, tracer::TracerConfig,
};
use tracing::{info, instrument};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // 初始化追踪器
    let config = TracerConfig {
        service_name: "example-service".to_string(),
        service_version: "1.0.0".to_string(),
        environment: "development".to_string(),
        ..Default::default()
    };

    init_tracer(config).await?;

    // 使用 tracing 的宏
    example_function().await;

    // 使用 SpanBuilder
    let _span = SpanBuilder::new("manual_operation")
        .with_kind(SpanKind::Client)
        .with_attribute("http.method", "GET")
        .with_attribute("http.url", "https://example.com/api")
        .start();

    info!("This is a log message within the span");

    // 关闭追踪器
    shutdown_tracer().await?;

    Ok(())
}

#[instrument]
async fn example_function() {
    info!("Executing example function");
    
    // 模拟一些工作
    tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
    
    nested_function().await;
}

#[instrument]
async fn nested_function() {
    info!("Executing nested function");
    
    // 模拟一些工作
    tokio::time::sleep(tokio::time::Duration::from_millis(50)).await;
}