Skip to content

Commit

Permalink
docs(metrics): add exmaple and feature hints
Browse files Browse the repository at this point in the history
  • Loading branch information
lennartkloock committed Jan 13, 2025
1 parent bf34afa commit 1be6323
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
4 changes: 4 additions & 0 deletions crates/metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ default = ["prometheus"]
tracing = ["internal-logs", "dep:tracing"]
extended-numbers = []

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.xtask]
additive-features = [
"prometheus",
Expand Down
25 changes: 24 additions & 1 deletion crates/metrics/derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
#![doc = include_str!("../README.md")]
//! # scuffle-metrics-derive
//!
//! A proc-macro to derive the `#[metrics]` attribute and the
//! `#[derive(MetricEnum)]` attribute.
//!
//! For more information checkout the [`scuffle-metrics`](../scuffle_metrics)
//! crate.
//!
//! ## Status
//!
//! This crate is currently under development and is not yet stable, unit tests
//! are not yet fully implemented.
//!
//! Unit tests are not yet fully implemented. Use at your own risk.
//!
//! ## License
//!
//! This project is licensed under the [MIT](./LICENSE.MIT) or
//! [Apache-2.0](./LICENSE.Apache-2.0) license. You can choose between one of
//! them if you use this work.
//!
//! `SPDX-License-Identifier: MIT OR Apache-2.0`
use enum_impl::metric_enum_impl;
use metrics_impl::metrics_impl;
Expand Down Expand Up @@ -39,6 +60,7 @@ mod metrics_impl;
/// pub fn request(kind: Kind) -> CounterU64;
/// }
///
/// // Increment the counter
/// example::request(example::Kind::Http).incr();
/// ```
///
Expand All @@ -54,6 +76,7 @@ mod metrics_impl;
/// #[scuffle_metrics::metrics(unit = "requests")]
/// pub fn request(kind: Kind) -> CounterU64;
///
/// // Increment the counter
/// request(Kind::Http).incr();
/// ```
#[proc_macro_attribute]
Expand Down
25 changes: 25 additions & 0 deletions crates/metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@
//! A wrapper around opentelemetry to provide a more ergonomic interface for
//! creating metrics.
//!
//! ## Example
//!
//! ```rust
//! #[scuffle_metrics::metrics]
//! mod example {
//! use scuffle_metrics::{MetricEnum, collector::CounterU64};
//!
//! #[derive(MetricEnum)]
//! pub enum Kind {
//! Http,
//! Grpc,
//! }
//!
//! #[metrics(unit = "requests")]
//! pub fn request(kind: Kind) -> CounterU64;
//! }
//!
//! // Increment the counter
//! example::request(example::Kind::Http).incr();
//! ```
//!
//! For details see [`metrics`].
//!
//! ## Status
//!
//! This crate is currently under development and is not yet stable.
Expand All @@ -16,8 +39,10 @@
//! them if you use this work.
//!
//! `SPDX-License-Identifier: MIT OR Apache-2.0`
#![cfg_attr(docsrs, feature(doc_cfg))]

#[cfg(feature = "prometheus")]
#[cfg_attr(docsrs, doc(cfg(feature = "prometheus")))]
/// A copy of the opentelemetry-prometheus crate, updated to work with the
/// latest version of opentelemetry.
pub mod prometheus;
Expand Down

0 comments on commit 1be6323

Please sign in to comment.