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
- Host: GitHub
- URL: https://github.com/max-te/runtime-otel-rs
- Owner: max-te
- License: apache-2.0
- Created: 2024-04-01T19:50:55.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-09T19:46:36.000Z (about 2 years ago)
- Last Synced: 2025-10-01T20:56:24.069Z (9 months ago)
- Language: Rust
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.Apache2
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)