metrics_exporter_opentelemetry/lib.rs
1// 🐻❄️🎈 metrics-exporter-opentelemetry: metrics exporter over OpenTelemetry
2// Copyright (c) 2025 Noelware, LLC. <team@noelware.org>
3//
4// Permission is hereby granted, free of charge, to any person obtaining a copy
5// of this software and associated documentation files (the "Software"), to deal
6// in the Software without restriction, including without limitation the rights
7// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8// copies of the Software, and to permit persons to whom the Software is
9// furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in all
12// copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20// SOFTWARE.
21
22//! # 🐻❄️🎈 `metrics-exporter-opentelemetry`
23//!
24//! The **metrics-exporter-opentelemetry** crate is a [`metrics`] exporter over
25//! OpenTelemetry's **metrics** API.
26//!
27//! ## Warnings
28//! - The crate doesn't support the following methods from [`metrics`]:
29//! - [`Counter::absolute`](https://docs.rs/metrics/latest/metrics/struct.Counter.html#method.absolute):
30//! OpenTelemetry doesn't keep track of the value inside a counter.
31//!
32//! - [`Gauge::increment`](https://docs.rs/metrics/latest/metrics/struct.Gauge.html#method.increment),
33//! [`Gauge::decrement`](https://docs.rs/metrics/latest/metrics/struct.Gauge.html#method.decrement):
34//! OpenTelemetry doesn't keep track of the value inside a gauge.
35//!
36//! - [`Histogram::record_many`](https://docs.rs/metrics/latest/metrics/struct.Histogram.html#method.record_many):
37//! OpenTelemetry doesn't support recording multiple histogram points.
38//!
39//! - The crate provide no-op implementations of the `metrics::Recorder::describe_*` as we
40//! can't modify a constructed counter/gauge/histogram from
41//! `metrics::Recorder::register_*`. The SDK keeps track of it but is internal and isn't
42//! able to be accessed.
43//!
44//! ## Usage
45//! ```rust
46//! // Cargo.toml:
47//! //
48//! // [dependencies]
49//! // metrics = "^0"
50//! // metrics-exporter-opentelemetry = "^0"
51//!
52//! use metrics_exporter_opentelemetry::Recorder;
53//!
54//! # fn main() {
55//! // Install a global `metrics` recorder
56//! let _ = Recorder::builder("my-app")
57//! .install_global()
58//! .unwrap();
59//!
60//! let counter = metrics::counter!("hello.world");
61//! counter.increment(1);
62//! # }
63//! ```
64//!
65//! [`metrics`]: https://crates.io/crates/metrics
66
67#![cfg_attr(any(noeldoc, docsrs), feature(doc_cfg))]
68#![doc(html_logo_url = "https://cdn.floofy.dev/images/trans.png")]
69#![doc(html_favicon_url = "https://cdn.floofy.dev/images/trans.png")]
70
71mod error;
72mod recorder;
73
74pub use error::*;
75pub use recorder::*;