Crates.io | fastrace-opentelemetry |
lib.rs | fastrace-opentelemetry |
version | |
source | src |
created_at | 2024-07-16 10:10:51.779811 |
updated_at | 2024-11-18 08:46:59.276252 |
description | Opentelemetry reporter for fastrace |
homepage | |
repository | https://github.com/fast/fastrace |
max_upload_size | |
id | 1304906 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
OpenTelemetry reporter for fastrace
.
[dependencies]
fastrace = "0.7"
fastrace-opentelemetry = "0.7"
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/
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::new([KeyValue::new("service.name", "asynchronous")])),
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()