Crates.io | opentelemetry-surf |
lib.rs | opentelemetry-surf |
version | 0.6.0 |
source | src |
created_at | 2020-12-06 07:34:56.785585 |
updated_at | 2022-02-15 19:11:47.240939 |
description | OpenTelemetry integration for surf |
homepage | https://github.com/asaaki/opentelemetry-surf |
repository | https://github.com/asaaki/opentelemetry-surf |
max_upload_size | |
id | 320082 |
size | 100,609 |
OpenTelemetry integration for Surf
Add OpenTelemetry tracing support to your Surf clients. Be part of the new observability movement!
# Run jaeger in background
docker run -d \
-p6831:6831/udp -p6832:6832/udp -p16686:16686 -p14268:14268 \
jaegertracing/all-in-one:latest
# Run simple client example with tracing middleware
cargo run --example simple
# Run metrics client example (uses isahc with metrics enabled)
cargo run --example metrics --features isahc-metrics
# Open browser and view the traces
firefox http://localhost:16686/
Cargo.toml
async-std = { version = "1.10", features = ["attributes"] }
opentelemetry = { version = "0.17", features = ["rt-async-std"] }
opentelemetry-jaeger = { version = "0.16", features = ["rt-async-std"] }
opentelemetry-surf = "0.6"
client.rs
#[async_std::main]
async fn main() -> surf::Result<()> {
let _tracer = opentelemetry_jaeger::new_pipeline().install_batch(opentelemetry::runtime::AsyncStd)?;
let otel_mw = opentelemetry_surf::OpenTelemetryTracingMiddleware::default();
let client = surf::client().with(otel_mw);
let res = client.get("https://httpbin.org/get").await?;
dbg!(res);
opentelemetry::global::shutdown_tracer_provider();
Ok(())
}
flag | description |
---|---|
isahc-metrics |
enables more details when using a custom ishac client configuration, see examples/client/metrics.rs for details |
This crate uses #![forbid(unsafe_code)]
to ensure everything is implemented in 100% Safe Rust.