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

influxive-otel-atomic-obs

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

8 releases

new 0.0.4-alpha.1 Feb 19, 2025
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

#600 in Development tools

Download history 687/week @ 2024-10-30 619/week @ 2024-11-06 757/week @ 2024-11-13 458/week @ 2024-11-20 611/week @ 2024-11-27 346/week @ 2024-12-04 579/week @ 2024-12-11 395/week @ 2024-12-18 92/week @ 2024-12-25 408/week @ 2025-01-01 717/week @ 2025-01-08 583/week @ 2025-01-15 471/week @ 2025-01-22 536/week @ 2025-01-29 947/week @ 2025-02-05 639/week @ 2025-02-12

2,649 downloads per month
Used in 20 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
~54K SLoC