Crates.io | metry |
lib.rs | metry |
version | 0.1.1 |
source | src |
created_at | 2024-07-31 08:28:13.401602 |
updated_at | 2024-08-06 20:04:21.852619 |
description | All-in-one telemetry framework, based on tracing crate. |
homepage | https://github.com/ottofeller/telemetry/tree/main/metry |
repository | https://github.com/ottofeller/telemetry.git |
max_upload_size | |
id | 1320732 |
size | 40,959 |
This crate contains the API for telemetry setup in Rust.
This crate supplements tracing library and provides an easy way to setup providers for collection of logs, metrics and traces.
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.
Stdout
and Stderr
.Stdout
and CloudWatch
.Stdout
and Xray
.To have the telemetry collected one needs to:
use metry::telemetry;
telemetry::new()
.with_stdout_logs()
.with_aws_metrics()
.with_aws_traces()
.init()
.await;
use tracing::{info, info_span};
// Emit a log event with level info
info!("Started execution");
// Start a synchronous trace span
let span = info_span!("my sync span");
span.in_scope(|| {
info!("This event is recorder within the trace span");
// Do work inside the span...
// Collect metrics: count on foo
info!(monotonic_counter.foo = 1);
});
// Run async code in a future with a span attached
let future_result: Vec<u64> = some_future
.instrument(tracing::info_span!("my async span"))
.await;
// Collect metrics: put data into the bar histogram
info!(histogram.bar = future_result);
info!("Execution complete");