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

fastrace-opentelemetry

Opentelemetry reporter for fastrace

9 unstable releases (3 breaking)

new 0.9.0 Feb 11, 2025
0.8.1 Feb 3, 2025
0.8.0 Nov 18, 2024
0.7.4 Oct 27, 2024
0.6.8 Jul 16, 2024

#354 in Debugging

Download history 2220/week @ 2024-10-29 1532/week @ 2024-11-05 1951/week @ 2024-11-12 2489/week @ 2024-11-19 2268/week @ 2024-11-26 2177/week @ 2024-12-03 2447/week @ 2024-12-10 2346/week @ 2024-12-17 1706/week @ 2024-12-24 4358/week @ 2024-12-31 6946/week @ 2025-01-07 5188/week @ 2025-01-14 6581/week @ 2025-01-21 17383/week @ 2025-01-28 18500/week @ 2025-02-04 12802/week @ 2025-02-11

56,054 downloads per month

Apache-2.0

195KB
4K SLoC

fastrace-opentelemetry

Documentation Crates.io LICENSE

OpenTelemetry reporter for fastrace.

Dependencies

[dependencies]
fastrace = "0.7"
fastrace-opentelemetry = "0.9"

Setup OpenTelemetry Collector

Start OpenTelemetry Collector with Jaeger and Zipkin receivers:

docker compose -f examples/docker-compose.yaml up

Then, run the synchronous example:

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 fastrace::collector::Config;
use fastrace::prelude::*;
use fastrace_opentelemetry::OpenTelemetryReporter;
use opentelemetry_otlp::ExportConfig;
use opentelemetry_otlp::Protocol;
use opentelemetry_otlp::SpanExporter;
use opentelemetry_otlp::TonicConfig;
use opentelemetry::trace::SpanKind;
use opentelemetry_sdk::Resource;
use opentelemetry::KeyValue;
use opentelemetry::InstrumentationScope;
use opentelemetry_otlp::WithExportConfig;

// Initialize reporter
let reporter = OpenTelemetryReporter::new(
    SpanExporter::builder()
        .with_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()
        .expect("initialize oltp exporter"),
    SpanKind::Server,
    Cow::Owned(
        Resource::builder()
            .with_attributes([KeyValue::new("service.name", "asynchronous")])
            .build()
    ),
    InstrumentationScope::builder("example-crate").with_version(env!("CARGO_PKG_VERSION")).build(),
);
fastrace::set_reporter(reporter, Config::default());

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

fastrace::flush()

Dependencies

~4–10MB
~96K SLoC

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy