1 unstable release
0.0.0 | Dec 10, 2020 |
---|
#22 in #honeycomb
2KB
OpenTelemetry Exporter for Honeycomb (Unofficial)
Getting Started
use std::sync::Arc;
use async_executors::TokioTpBuilder;
use opentelemetry::trace::Tracer;
use opentelemetry::global::shutdown_tracer_provider;
use opentelemetry_honeycomb::HoneycombApiKey;
fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
let mut builder = TokioTpBuilder::new();
builder
.tokio_builder()
.enable_time()
.enable_io();
let executor = Arc::new(builder.build().expect("Failed to build Tokio executor"));
// Create a new instrumentation pipeline.
let (_flusher, tracer) = opentelemetry_honeycomb::new_pipeline(
HoneycombApiKey::new(
std::env::var("HONEYCOMB_API_KEY")
.expect("Missing or invalid environment variable HONEYCOMB_API_KEY")
),
std::env::var("HONEYCOMB_DATASET")
.expect("Missing or invalid environment variable HONEYCOMB_DATASET"),
executor.clone(),
move |fut| executor.block_on(fut),
)
.install()?;
tracer.in_span("doing_work", |cx| {
// Traced app logic here...
});
shutdown_tracer_provider();
Ok(())
}