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

minitrace-opentelemetry

Opentelemetry reporter for minitrace-rust

10 releases

0.6.7 Jun 23, 2024
0.6.6 May 31, 2024
0.6.4 Feb 8, 2024
0.6.3 Jan 26, 2024
0.5.0 Jul 28, 2023

#16 in #jaeger

Download history 3331/week @ 2024-06-27 3780/week @ 2024-07-04 3774/week @ 2024-07-11 2566/week @ 2024-07-18 2159/week @ 2024-07-25 901/week @ 2024-08-01 1751/week @ 2024-08-08 3317/week @ 2024-08-15 1724/week @ 2024-08-22 1981/week @ 2024-08-29 1704/week @ 2024-09-05 1527/week @ 2024-09-12 1114/week @ 2024-09-19 785/week @ 2024-09-26 1063/week @ 2024-10-03 836/week @ 2024-10-10

4,186 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

~3–9MB
~80K SLoC