Switch from `log` crate to `tracing`, integrate OpenTelemetry
Opened this issue · 0 comments
emanguy commented
The Tracing crate is a drop-in replacement for the old log
logging facade. It also supports redirecting logs from the old facade as well to allow third-party libraries to hook into the logger as well.
What it adds on top of log
is support for distributed tracing and metrics which can be redirected to any OpenTelementry logs/traces/metrics collectors, which empowers enhanced debugging techniques and visibility into microservices.
Here's what needs to be done:
- Add the tracing crate to the template's dependencies. Replace any usages of
log::info!
/log::debug!
/log::warn!
/etc. with the "tracing" equivalents - Add an OpenTelemetry subscriber to the default tracer
- Add the Axum OpenTelemetry layer to the app bootstrapping process
- Add the Reqwest tracing middleware to an easily accessible HTTP client
- Add tracing-specific documentation to
doc/logging.md
- Add an OTel subscriber to the included docker compose file (maybe Jaeger?) to demonstrate distributed tracing capability