#open-telemetry #metrics #atomic #observable #sync #influxive #obs

influxive-otel-atomic-obs

Opentelemetry observable metric implementations based on std::sync::atomic types

7 releases

0.0.3-alpha.1 Jun 5, 2024
0.0.2-alpha.1 Oct 16, 2023
0.0.1-alpha.11 Aug 4, 2023
0.0.1-alpha.9 Jul 31, 2023

#615 in Development tools

Download history 728/week @ 2024-07-26 755/week @ 2024-08-02 557/week @ 2024-08-09 515/week @ 2024-08-16 549/week @ 2024-08-23 642/week @ 2024-08-30 700/week @ 2024-09-06 724/week @ 2024-09-13 936/week @ 2024-09-20 384/week @ 2024-09-27 602/week @ 2024-10-04 524/week @ 2024-10-11 442/week @ 2024-10-18 736/week @ 2024-10-25 560/week @ 2024-11-01 675/week @ 2024-11-08

2,563 downloads per month
Used in 18 crates (2 directly)

MIT/Apache

26KB
594 lines

Opentelemetry observable metric implementations based on std::sync::atomic types. Opentelemetry has a concept of "observable" metrics that are not reported as they are updated, but rather, when an update happens, they are polled. For ease-of-use in code, it is often desirable to have these metrics be backed by std::sync::atomic types, so that they can be easily updated throughout the code, and fetched whenever a metric reporting poll occurs. This crate provides the [MeterExt] trait and associated types to make it easy to use std::sync::atomic backed metrics with opentelemetry.

Example

use influxive_otel_atomic_obs::MeterExt;

let (my_metric, _) = opentelemetry_api::global::meter("my_meter")
    .u64_observable_gauge_atomic("my_metric", 0)
    .init();

my_metric.set(66); // probably will not be reported
my_metric.set(99); // probably will not be reported
my_metric.set(42); // will be reported next time reporting runs

Dependencies

~2–3MB
~56K SLoC