[go: up one dir, main page]

Skip to content

equinix-labs/rust-otel-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-otel-tools

Some reusable otel code for Equinix rust applications

Example:

use opentelemetry::trace::Tracer;

#[tracing::instrument(err)]
async fn something(message: String) -> Result<(), Box<dyn std::error::Error>> {
    // This will mark the span as an error even though it returns Ok(())
    tracing::error!("Error: {}", message);
    Ok(())
}

#[tokio::main]
async fn main() {
    // Set up the otel exporter based on the the otlp exporter environment variables
    // <https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/>
    let _ = equinix_otel_tools::init("example-service");

    // Set up a new active span, parsing the TRACEPARENT environment variable
    // if it's valid
    let guard = equinix_otel_tools::start_with_traceparent("example");

    // call an instrumented function
    something("Hello World".to_string()).await;

    drop(guard);
    opentelemetry::global::shutdown_tracer_provider();
}

About

Some reusable otel code for Equinix rust applications

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published