#open-telemetry #tracing #jaeger #spans #datadog

minitrace-opentelemetry

Opentelemetry reporter for minitrace-rust

7 releases

0.6.4 Feb 8, 2024
0.6.3 Jan 26, 2024
0.6.2 Nov 2, 2023
0.6.1 Oct 28, 2023
0.5.0 Jul 28, 2023

#604 in Debugging

Download history 1801/week @ 2023-12-23 1433/week @ 2023-12-30 1938/week @ 2024-01-06 2855/week @ 2024-01-13 2986/week @ 2024-01-20 2491/week @ 2024-01-27 2142/week @ 2024-02-03 373/week @ 2024-02-10 1959/week @ 2024-02-17 2867/week @ 2024-02-24 2408/week @ 2024-03-02 1876/week @ 2024-03-09 2693/week @ 2024-03-16 2624/week @ 2024-03-23 2013/week @ 2024-03-30 2611/week @ 2024-04-06

10,385 downloads per month

Apache-2.0

180KB
3.5K SLoC

minitrace-opentelemetry

Documentation Crates.io LICENSE

OpenTelemetry reporter for minitrace.

Dependencies

[dependencies]
minitrace = "0.6"
minitrace-opentelemetry = "0.6"

Setup OpenTelemetry Collector

cd minitrace-opentelemetry/examples
docker compose up -d

cargo run --example synchronous

Jaeger UI is available on http://127.0.0.1:16686/

Zipkin UI is available on http://127.0.0.1:9411/

Report to OpenTelemetry Collector

use std::borrow::Cow;
use std::time::Duration;
use minitrace::collector::Config;
use minitrace::prelude::*;
use minitrace_opentelemetry::OpenTelemetryReporter;
use opentelemetry_otlp::{SpanExporter, ExportConfig, Protocol, TonicConfig};
use opentelemetry::trace::SpanKind;
use opentelemetry_sdk::Resource;
use opentelemetry::KeyValue;
use opentelemetry::InstrumentationLibrary;
use opentelemetry_otlp::WithExportConfig;

// Initialize reporter
let reporter = OpenTelemetryReporter::new(
    opentelemetry_otlp::new_exporter()
        .tonic()
        .with_endpoint("http://127.0.0.1:4317".to_string())
        .with_protocol(opentelemetry_otlp::Protocol::Grpc)
        .with_timeout(Duration::from_secs(
            opentelemetry_otlp::OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT,
        ))
        .build_span_exporter()
        .expect("initialize oltp exporter"),
    SpanKind::Server,
    Cow::Owned(Resource::new([KeyValue::new("service.name", "asynchronous")])),
    InstrumentationLibrary::new("example-crate", Some(env!("CARGO_PKG_VERSION")), None::<&'static str>, None),
);
minitrace::set_reporter(reporter, Config::default());

{
    // Start tracing
    let root = Span::root("root", SpanContext::random());
}

minitrace::flush()

Dependencies

~4–12MB
~94K SLoC