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

influxive-otel-atomic-obs

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

6 releases

0.0.2-alpha.1 Oct 16, 2023
0.0.1-alpha.11 Aug 4, 2023
0.0.1-alpha.10 Aug 1, 2023
0.0.1-alpha.9 Jul 31, 2023
0.0.1-alpha.8 Jul 28, 2023

#457 in Development tools

Download history 235/week @ 2023-12-23 167/week @ 2023-12-30 451/week @ 2024-01-06 403/week @ 2024-01-13 510/week @ 2024-01-20 508/week @ 2024-01-27 791/week @ 2024-02-03 201/week @ 2024-02-10 444/week @ 2024-02-17 383/week @ 2024-02-24 645/week @ 2024-03-02 418/week @ 2024-03-09 810/week @ 2024-03-16 423/week @ 2024-03-23 409/week @ 2024-03-30 636/week @ 2024-04-06

2,357 downloads per month
Used in 22 crates (2 directly)

MIT/Apache

26KB
574 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.1–3MB
~56K SLoC