4 releases
0.7.2 | Aug 16, 2024 |
---|---|
0.7.1 | Aug 14, 2024 |
0.7.0 | Aug 14, 2024 |
0.6.8 | Jul 16, 2024 |
#593 in Debugging
5,506 downloads per month
185KB
4K
SLoC
fastrace-opentelemetry
OpenTelemetry reporter for fastrace
.
Dependencies
[dependencies]
fastrace = "0.7"
fastrace-opentelemetry = "0.7"
Setup OpenTelemetry Collector
cd fastrace-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 fastrace::collector::Config;
use fastrace::prelude::*;
use fastrace_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),
);
fastrace::set_reporter(reporter, Config::default());
{
// Start tracing
let root = Span::root("root", SpanContext::random());
}
fastrace::flush()
Dependencies
~3–8.5MB
~75K SLoC