Ottofeller telemetry library
This crate contains the API for telemetry setup in Rust.
Overview
This crate supplements tracing library and provides an easy way to setup providers for collection of logs, metrics and traces.
What does this crate contain?
- Telemetry API: Provides a way to setup collection of logs, metrics and traces with a choice of preconfigured providers.
The other modules are provide a way to fine-tune telemetry during setup. They contain reasonable defalts as well as allow configuration in the scope of exposed API.
- Logs:
A collection of log providers. Available options are
StdoutandStderr. - Metrics:
A collection of log providers. Available options are
StdoutandCloudWatch. - Traces:
A collection of log providers. Available options are
StdoutandXray.
Getting started
To have the telemetry collected one needs to:
- setup providers for each type of telemetry;
- instrument the code with relevant events.
Setup telemetry
use telemetry;
new
.with_stdout_logs
.with_aws_metrics
.with_aws_traces
.init
.await;
Instrument your code
use ;
// Emit a log event with level info
info!;
// Start a synchronous trace span
let span = info_span!;
span.in_scope;
// Run async code in a future with a span attached
let future_result: = some_future
.instrument
.await;
// Collect metrics: put data into the bar histogram
info!;
info!;