An open API service indexing awesome lists of open source software.

https://github.com/max-te/runtime-otel-rs

(Experimental) Register runtime metrics in opentelemetry
https://github.com/max-te/runtime-otel-rs

Last synced: 4 months ago
JSON representation

(Experimental) Register runtime metrics in opentelemetry

Awesome Lists containing this project

README

          

# runtime-otel-metrics

runtime-otel-metrics is an experimental crate that enables you to meter your tokio runtime and memory usage with [OpenTelemetry](https://crates.io/crates/opentelemetry).
For tokio metrics it leans on [tokio's unstable runtime metrics](https://docs.rs/tokio/latest/tokio/runtime/struct.RuntimeMetrics.html).
For memory usage we use the [memory-stats](https://crates.io/crates/memory-stats) crate.

## Usage

To use the `tokio` feature, you must compile with the rustc flag `--cfg tokio_unstable`.

```rust
// Register Tokio metrics with OpenTelemetry
runtime_otel_metrics::tokio_rt::register_tokio_metrics(
tokio::runtime::Handle::current(),
&opentelemetry::global::meter("tokio"),
)?;

// Register memory metrics
runtime_otel_metrics::memory::register(&opentelemetry::global::meter("memory"))?;
```

## Similar crates

- [tokio-metrics-collector](https://crates.io/crates/tokio-metrics-collector)