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?;
example_function().await;
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;
}