scuffle-metrics

Crates.ioscuffle-metrics
lib.rsscuffle-metrics
version0.4.2
created_at2024-11-28 17:14:45.175011+00
updated_at2025-08-06 13:31:51.039659+00
descriptionHelper crate to instrument your code with metrics.
homepage
repositoryhttps://github.com/scufflecloud/scuffle
max_upload_size
id1464809
size115,895
Developers (github:scufflecloud:developers)

documentation

https://docs.rs/scuffle-metrics

README

scuffle-metrics

[!WARNING]
This crate is under active development and may not be stable.

License: MIT OR Apache-2.0 docs.rs crates.io GitHub Actions: ci Codecov


A wrapper around opentelemetry to provide a more ergonomic interface for creating metrics.

This crate can be used together with the scuffle-bootstrap-telemetry crate which provides a service that integrates with the scuffle-bootstrap ecosystem.

See the changelog for a full release history.

Feature flags

  • prometheus (enabled by default) — Enables prometheus support
  • tracing — Enables tracing support
  • docs — Enables changelog and documentation of feature flags

Example

#[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!.

License

This project is licensed under the MIT or Apache-2.0 license. You can choose between one of them if you use this work.

SPDX-License-Identifier: MIT OR Apache-2.0

Commit count: 1522

cargo fmt