OpenTelemetry integration for Surf
Notes
- It is heavily inspired by opentelemetry-tide crate; surf and tide share very similar middleware structure. Thank you, dear @http-rs folks! 🙇🏻♂️
- It only implements very basic request tracing on the middleware layer. If something is missing, create a PR or open an issue and describe your desired feature.
- (soon) It records http request/response life cycle events when used with isahc and its metrics enabled. (needs a change in http-client crate)
- You probably do not want to use it in production. 🤷
How to use
# 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/

Code example
Cargo.toml
= { = "1.7", = ["attributes"] }
= { = "0.10", = ["async-std"] }
= { = "0.9", = ["async-std"] }
= "0.1" # not yet released
= { = "https://github.com/asaaki/opentelemetry-surf", = "main" }
client.rs
async
Cargo Features:
Safety
This crate uses #![forbid(unsafe_code)] to ensure everything is implemented in
100% Safe Rust.