Skip to content

Commit

Permalink
Merge changes from fork (#2)
Browse files Browse the repository at this point in the history
* fix prometheus metric name and label key sanitizer (metrics-rs#296)

Co-authored-by: Toby Lawrence <tobz@users.noreply.github.com>

* metrics-util: add ability to collect metrics on a per-thread basis via DebuggingRecorder (metrics-rs#299)

Signed-off-by: Toby Lawrence <toby@nuclearfurnace.com>

* (cargo-release) version 0.12.1

* Improve handling of the global recorder instance (metrics-rs#302)

This gets rid of the dangerous `static mut`, adds more comments
about the code, relaxes the orderings and documents the unsoundness
of the `clear` function, in addition to marking it unsafe.

It implements a small once_cell-like abstraction.

Co-authored-by: Toby Lawrence <toby@nuclearfurnace.com>

* Fix `metrics::Cow` provenance issue (metrics-rs#303)

* Quantile Remapping Fix (metrics-rs#304)

* update changelogs prior to release

* (cargo-release) version 0.19.0

* (cargo-release) version 0.13.0

* (cargo-release) version 0.11.0

* (cargo-release) version 0.10.0

* Update CHANGELOG.md

* Update README.md

* Update ci.yml

* Update ci.yml

* Add RollingSummary to prevent summary saturation (metrics-rs#306)

* Update quanta requirement from 0.9.3 to 0.10.0 (metrics-rs#301)

Updates the requirements on [quanta](https://github.com/metrics-rs/quanta) to permit the latest version.
- [Release notes](https://github.com/metrics-rs/quanta/releases)
- [Changelog](https://github.com/metrics-rs/quanta/blob/main/CHANGELOG.md)
- [Commits](metrics-rs/quanta@v0.9.3...v0.10.0)

---
updated-dependencies:
- dependency-name: quanta
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Document CI enforced msrv in readme and rust-version fields (metrics-rs#311)

* Change description to be SharedString (metrics-rs#312)

* Update hashbrown requirement from 0.11 to 0.12 (metrics-rs#266)

Updates the requirements on [hashbrown](https://github.com/rust-lang/hashbrown) to permit the latest version.
- [Release notes](https://github.com/rust-lang/hashbrown/releases)
- [Changelog](https://github.com/rust-lang/hashbrown/blob/master/CHANGELOG.md)
- [Commits](rust-lang/hashbrown@v0.11.0...v0.12.0)

---
updated-dependencies:
- dependency-name: hashbrown
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Toby Lawrence <tobz@users.noreply.github.com>

* Shims remaining AtomicU64 usage (metrics-rs#313)

* Update parking_lot requirement from 0.11 to 0.12 (metrics-rs#268)

Updates the requirements on [parking_lot](https://github.com/Amanieu/parking_lot) to permit the latest version.
- [Release notes](https://github.com/Amanieu/parking_lot/releases)
- [Changelog](https://github.com/Amanieu/parking_lot/blob/master/CHANGELOG.md)
- [Commits](Amanieu/parking_lot@0.11.0...0.12.0)

---
updated-dependencies:
- dependency-name: parking_lot
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Toby Lawrence <tobz@users.noreply.github.com>

* update changelogs

* (cargo-release) version 0.13.1

* add std atomics handle support back + changelogs

* (cargo-release) version 0.20.0

* (cargo-release) version 0.14.0

* (cargo-release) version 0.11.0

* changelog

* (cargo-release) version 0.12.0

* (cargo-release) version 0.7.0

* update changelog

* (cargo-release) version 0.6.0

* update changelog

* (cargo-release) version 0.20.1

* Remove incorrect return info (metrics-rs#316)

* Add a `KeyName` argument to `LabelFilter::should_include_label` (metrics-rs#342)

* rewind

* (cargo-release) version 0.13.0

* Use std sync primitives instead of parking_lot. (metrics-rs#344)

* Use std::sync::Mutex instead of parking_lot::Mutex.
* Bump MSRV to 1.60.0 for CI.

Co-authored-by: Toby Lawrence <tobz@users.noreply.github.com>

* clean up github CI workflow + rust-toolchain.toml to match quanta

* update portable-atomic to 1.0

* bump to prost 0.11 + fix spelling issue in metrics-tracing-context

* bump MSRV to 1.61 + update hashbrown/ahash deps

* update termion/ordered-float and pin predicates-* to avoid stupid 1.64 MSRV

* update syn

* update quanta + clean up semver notation in cargo.toml

* cleanup README wording for MSRV policy

* Add white background to splash image (metrics-rs#348)

* Install protoc in CI.

* fix spelling error in CI workflow

* Update ci.yml

* no need to run CI against macOS/Windows specifically

* Bring the metrics-observer protobufs up to date (metrics-rs#345)

* Use global paths for macros (metrics-rs#358)

* fix changes to fully qualified metrics crate ref change in macros

* update changelog

* update tui to 0.19

* bump numpy dep

* impl std::error::Error for metrics_exporter_tcp::Error

* changelog

* tweak test to avoid unused code

* rework 32 vs 64-bit arch atomics support + a lot of import consolidation/cleanup

* const-ify some stuff + rewrite some comments for the global recorder init code

* clean up clippy lints

* bump MSRV to 1.61.0

* (cargo-release) version 0.7.0

* (cargo-release) version 0.21.0

* (cargo-release) version 0.15.0

* (cargo-release) version 0.14.0

* (cargo-release) version 0.8.0

* (cargo-release) version 0.12.0

* allow publishing

* (cargo-release) version 0.2.0

* make it publishable pt 2

* push-gateway support authentication (metrics-rs#366)

* update changelog + fix failing feature check test

* (cargo-release) version 0.12.1

* feat(util): new helper type for recovering recorder after installing it (metrics-rs#362)

* Update aho-corasick to 1.0.

* Impl From<std::borrow::Cow> for KeyName (metrics-rs#378)

* changelog

* Add `Borrow` impl to `KeyName` (metrics-rs#381)

* bump deps + clippy stuff

* changelog

* pin hashbrown to avoid MSRV bump

* (cargo-release) version 0.15.1

* (cargo-release) version 0.21.1

* Add metadata to metrics (metrics-rs#380)

* add https support in Prometheus gateway (metrics-rs#392)

* migrate from procedural to declarative macros (metrics-rs#386)

* Make `Unit` methods return `&'static str` where possible (metrics-rs#393)

* simplify macros (metrics-rs#394)

* Add support for `Arc<T>` to `metrics::Cow<'a, T>`. (metrics-rs#402)

* Add support for `tracing::Span::record`ed fields in `metrics-tracing-context` (metrics-rs#408)

* fix(prom): `RollingSummary` overflow panic (metrics-rs#423)

* update CHANGELOG

* (cargo-release) version 0.12.2

* Remove unneeded unsafe from test (metrics-rs#427)

* Fix feature check in CI (metrics-rs#428)

* update changelogs/release notes

* fix unsafe/incorrect crossbeam-epoch usage in Block<T>

* Add a clippy CI check (metrics-rs#416) (metrics-rs#417)

* Try other resolved addresses if the first one fails (metrics-rs#429)

* update changelog

* Update quanta requirement from 0.11 to 0.12 (metrics-rs#396)

Updates the requirements on [quanta](https://github.com/metrics-rs/quanta) to permit the latest version.
- [Changelog](https://github.com/metrics-rs/quanta/blob/v0.12.0/CHANGELOG.md)
- [Commits](metrics-rs/quanta@v0.11.0...v0.12.0)

---
updated-dependencies:
- dependency-name: quanta
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Toby Lawrence <tobz@users.noreply.github.com>

* Update ordered-float requirement from 3.4 to 4.2 (metrics-rs#421)

Updates the requirements on [ordered-float](https://github.com/reem/rust-ordered-float) to permit the latest version.
- [Release notes](https://github.com/reem/rust-ordered-float/releases)
- [Commits](reem/rust-ordered-float@v3.4.0...v4.2.0)

---
updated-dependencies:
- dependency-name: ordered-float
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix quantile api

* missing clear

* reintroduce old way to avoid big refactor

---------

Signed-off-by: Toby Lawrence <toby@nuclearfurnace.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Shaoyuan CHEN <chensy20@mails.tsinghua.edu.cn>
Co-authored-by: Toby Lawrence <tobz@users.noreply.github.com>
Co-authored-by: Toby Lawrence <toby@nuclearfurnace.com>
Co-authored-by: nils <48135649+Nilstrieb@users.noreply.github.com>
Co-authored-by: Dan Wilbanks <78116928+dfwilbanks395@users.noreply.github.com>
Co-authored-by: Daniel Nelson <daniel@wavesofdawn.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Lucas Kent <rubickent@gmail.com>
Co-authored-by: Fredrik Enestad <fredrik@enestad.com>
Co-authored-by: Christopher Hunt <huntchr@gmail.com>
Co-authored-by: zohnannor <35764628+zohnannor@users.noreply.github.com>
Co-authored-by: Sinotov Aleksandr <bratsinot@gmail.com>
Co-authored-by: Jacob Kiesel <kieseljake@live.com>
Co-authored-by: C J Silverio <ceejceej@gmail.com>
Co-authored-by: CinchBlue <aytasato@gmail.com>
Co-authored-by: JasonLi <lijingxuan92@126.com>
Co-authored-by: Mostafa Elhemali <mostafa.elhemaly@gmail.com>
Co-authored-by: Harry Barber <106155934+hlbarber@users.noreply.github.com>
Co-authored-by: Qingwen Zhao <864593343@qq.com>
Co-authored-by: david-perez <d@vidp.dev>
Co-authored-by: Lucio Franco <luciofranco14@gmail.com>
Co-authored-by: Nicolas Stinus <nicolas.stinus@gmail.com>
Co-authored-by: Valeriy V. Vorotyntsev <valery.vv@gmail.com>
  • Loading branch information
1 parent 8a130ca commit 9e8351e
Show file tree
Hide file tree
Showing 85 changed files with 4,204 additions and 3,138 deletions.
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ updates:
- package-ecosystem: cargo
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
interval: weekly
open-pull-requests-limit: 10
105 changes: 45 additions & 60 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,88 +10,73 @@ jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install Rust Nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt, clippy
run: rustup default nightly
- name: Check Formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
run: cargo fmt --all -- --check
feature-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: actions/checkout@v3
- name: Install Protobuf Compiler
run: sudo apt-get install protobuf-compiler
- name: Install Rust Stable
run: rustup default stable
- name: Install cargo-hack
uses: actions-rs/cargo@v1
uses: taiki-e/install-action@v2
with:
command: install
args: cargo-hack
tool: cargo-hack
- name: Check Feature Matrix
uses: actions-rs/cargo@v1
with:
command: hack
args: build --all --all-targets --feature-powerset
run: cargo hack check --all --all-targets --feature-powerset --release
test:
name: Test ${{ matrix.rust_version }}/${{ matrix.os }}
runs-on: ${{ matrix.os }}
name: Test ${{ matrix.rust_version }}
runs-on: ubuntu-latest
strategy:
matrix:
rust_version: ['1.55.0', 'stable', 'nightly']
os: [ubuntu-latest, windows-latest, macOS-latest]
rust_version: ['1.61.0', 'stable', 'nightly']
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Install Protobuf Compiler
run: sudo apt-get install protobuf-compiler
- name: Install Rust ${{ matrix.rust_version }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust_version }}
override: true
run: rustup default ${{ matrix.rust_version }}
- name: Run Tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --workspace --exclude=metrics-observer
run: cargo test --all-features --workspace --exclude=metrics-observer -- --test-threads=1
docs:
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: -Dwarnings
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install Protobuf Compiler
run: sudo apt-get install protobuf-compiler
- name: Install Rust Nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rust-docs
run: rustup default nightly
- name: Check Docs
uses: actions-rs/cargo@v1
with:
command: doc
args: --all-features --workspace --exclude=metrics-observer --no-deps
run: cargo doc --all-features --workspace --exclude=metrics-observer --no-deps
bench:
name: Bench ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
name: Bench
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Install Protobuf Compiler
run: sudo apt-get install protobuf-compiler
- name: Install Rust Stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
run: rustup default stable
- name: Run Benchmarks
uses: actions-rs/cargo@v1
with:
command: bench
args: --all-features --workspace --exclude=metrics-observer
run: cargo bench --all-features --workspace --exclude=metrics-observer
clippy:
name: Clippy ${{ matrix.rust_version }}
runs-on: ubuntu-latest
strategy:
matrix:
rust_version: ['1.61.0', 'stable', 'nightly']
steps:
- uses: actions/checkout@v3
- name: Install Protobuf Compiler
run: sudo apt-get install protobuf-compiler
- name: Install Rust ${{ matrix.rust_version }}
run: rustup default ${{ matrix.rust_version }}
- name: Run Clippy
run: cargo clippy --all-features --workspace --exclude=metrics-observer
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[workspace]
members = [
"metrics",
"metrics-macros",
"metrics-util",
"metrics-exporter-tcp",
"metrics-exporter-prometheus",
Expand Down
29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,46 @@ If you're a library author, you'll only care about using [`metrics`][metrics] to
Overall, this repository is home to the following crates:

* [`metrics`][metrics]: A lightweight metrics facade, similar to [`log`][log].
* [`metrics-macros`][metrics-macros]: Procedural macros that power `metrics`.
* [`metrics-tracing-context`][metrics-tracing-context]: Allow capturing [`tracing`][tracing] span
fields as metric labels.
* [`metrics-exporter-tcp`][metrics-exporter-tcp]: A `metrics`-compatible exporter for serving metrics over TCP.
* [`metrics-exporter-prometheus`][metrics-exporter-prometheus]: A `metrics`-compatible exporter for
serving a Prometheus scrape endpoint.
* [`metrics-util`][metrics-util]: Helper types/functions used by the `metrics` ecosystem.

# community integrations

As well, there are also some community-maintained exporters and other integrations:

* [`metrics-exporter-statsd`][metrics-exporter-statsd]: A `metrics`-compatible exporter for sending metrics via StatsD.
* [`metrics-exporter-newrelic`][metrics-exporter-newrelic]: A `metrics`-compatible exporter for sending metrics to New Relic.
* [`opinionated_metrics`][opinionated-metrics]: Opinionated interface to emitting metrics for CLI/server applications, based on `metrics`.

## MSRV and MSRV policy

Minimum supported Rust version (MSRV) is currently **1.61.0**, enforced by CI.

`metrics` will always support _at least_ the latest four versions of stable Rust, based on minor
version releases, and excluding patch versions. Overall, we strive to support older versions where
possible, which means that we generally try to avoid staying up-to-date with every single dependency
(except for security/correctness reasons) and avoid bumping the MSRV just to get access to new
helper methods in the standard library, and so on.

# contributing

We're always looking for users who have thoughts on how to make `metrics` better, or users with interesting use cases. Of course, we're also happy to accept code contributions for outstanding feature requests! 😀
To those of you who have already contributed to `metrics` in some way, shape, or form: **a big, and continued, "thank you!"** ❤️

To everyone else that we haven't had the pleasure of interacting with: we're always looking for thoughts on how to make `metrics` better, or users with interesting use cases. Of course, we're also happy to accept code contributions for outstanding feature requests directly. 😀

We'd love to chat about any of the above, or anything else, really! You can find us over on [Discord](https://discord.gg/eTwKyY9).
We'd love to chat about any of the above, or anything else related to metrics. Don't hesitate to file an issue on the repository, or come and chat with us over on [Discord](https://discord.gg/eTwKyY9).

[metrics]: https://github.com/metrics-rs/metrics/tree/main/metrics
[metrics-macros]: https://github.com/metrics-rs/metrics/tree/main/metrics-macros
[metrics-tracing-context]: https://github.com/metrics-rs/metrics/tree/main/metrics-tracing-context
[metrics-exporter-tcp]: https://github.com/metrics-rs/metrics/tree/main/metrics-exporter-tcp
[metrics-exporter-prometheus]: https://github.com/metrics-rs/metrics/tree/main/metrics-exporter-prometheus
[metrics-util]: https://github.com/metrics-rs/metrics/tree/main/metrics-util
[log]: https://docs.rs/log
[tracing]: https://tracing.rs
[metrics-exporter-statsd]: https://docs.rs/metrics-exporter-statsd
[metrics-exporter-newrelic]: https://docs.rs/metrics-exporter-newrelic
[opinionated-metrics]: https://docs.rs/opinionated_metrics
Binary file modified assets/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 6 additions & 5 deletions metrics-benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ name = "metrics-benchmark"
version = "0.1.1-alpha.5"
authors = ["Toby Lawrence <toby@nuclearfurnace.com>"]
edition = "2018"
rust-version = "1.61.0"
publish = false

[dependencies]
log = "0.4"
pretty_env_logger = "0.4"
pretty_env_logger = "0.5"
getopts = "0.2"
hdrhistogram = { version = "7.2", default-features = false }
quanta = "0.9.3"
atomic-shim = "0.2"
metrics = { version = "^0.18", path = "../metrics" }
metrics-util = { version = "^0.12", path = "../metrics-util" }
quanta = "0.12"
portable-atomic = { version = "1", default-features = false, features = ["fallback"] }
metrics = { version = "0.21", path = "../metrics" }
metrics-util = { version = "0.15", path = "../metrics-util" }
30 changes: 15 additions & 15 deletions metrics-benchmark/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use atomic_shim::AtomicU64;
use getopts::Options;
use hdrhistogram::Histogram as HdrHistogram;
use log::{error, info};
use metrics::{
gauge, histogram, increment_counter, register_counter, register_gauge, register_histogram,
Counter, Gauge, Histogram, Key, KeyName, Recorder, Unit,
counter, gauge, histogram, Counter, Gauge, Histogram, Key, KeyName, Metadata, Recorder,
SharedString, Unit,
};
use metrics_util::registry::{AtomicStorage, Registry};
use portable_atomic::AtomicU64;
use quanta::{Clock, Instant as QuantaInstant};
use std::{
env,
Expand Down Expand Up @@ -62,21 +62,21 @@ impl BenchmarkingRecorder {
}

impl Recorder for BenchmarkingRecorder {
fn describe_counter(&self, _: KeyName, _: Option<Unit>, _: &'static str) {}
fn describe_counter(&self, _: KeyName, _: Option<Unit>, _: SharedString) {}

fn describe_gauge(&self, _: KeyName, _: Option<Unit>, _: &'static str) {}
fn describe_gauge(&self, _: KeyName, _: Option<Unit>, _: SharedString) {}

fn describe_histogram(&self, _: KeyName, _: Option<Unit>, _: &'static str) {}
fn describe_histogram(&self, _: KeyName, _: Option<Unit>, _: SharedString) {}

fn register_counter(&self, key: &Key) -> Counter {
fn register_counter(&self, key: &Key, _metadata: &Metadata<'_>) -> Counter {
self.registry.get_or_create_counter(key, |c| Counter::from_arc(c.clone()))
}

fn register_gauge(&self, key: &Key) -> Gauge {
fn register_gauge(&self, key: &Key, _metadata: &Metadata<'_>) -> Gauge {
self.registry.get_or_create_gauge(key, |g| Gauge::from_arc(g.clone()))
}

fn register_histogram(&self, key: &Key) -> Histogram {
fn register_histogram(&self, key: &Key, _metadata: &Metadata<'_>) -> Histogram {
self.registry.get_or_create_histogram(key, |h| Histogram::from_arc(h.clone()))
}
}
Expand Down Expand Up @@ -120,9 +120,9 @@ impl Generator {
if let Some(t0) = self.t0 {
let start = if loop_counter % LOOP_SAMPLE == 0 { Some(clock.now()) } else { None };

increment_counter!("ok");
gauge!("total", self.gauge as f64);
histogram!("ok", t1.sub(t0));
counter!("ok").increment(1);
gauge!("total").set(self.gauge as f64);
histogram!("ok").record(t1.sub(t0));

if let Some(val) = start {
let delta = clock.now() - val;
Expand All @@ -145,9 +145,9 @@ impl Generator {
let clock = Clock::new();
let mut loop_counter = 0;

let counter = register_counter!("ok");
let gauge = register_gauge!("total");
let histogram = register_histogram!("ok");
let counter = counter!("ok");
let gauge = gauge!("total");
let histogram = histogram!("ok");

loop {
loop_counter += 1;
Expand Down
Loading

0 comments on commit 9e8351e

Please sign in to comment.