Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: metrics-rs/metrics
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: metrics-v0.21.0
Choose a base ref
...
head repository: metrics-rs/metrics
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: metrics-v0.21.1
Choose a head ref

Commits on Apr 16, 2023

  1. (cargo-release) version 0.15.0

    tobz committed Apr 16, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    tobz Toby Lawrence
    Copy the full SHA
    9108ad5 View commit details
  2. (cargo-release) version 0.14.0

    tobz committed Apr 16, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    tobz Toby Lawrence
    Copy the full SHA
    ccb9a90 View commit details
  3. (cargo-release) version 0.8.0

    tobz committed Apr 16, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    tobz Toby Lawrence
    Copy the full SHA
    e659c36 View commit details
  4. (cargo-release) version 0.12.0

    tobz committed Apr 16, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    tobz Toby Lawrence
    Copy the full SHA
    78aad2b View commit details
  5. allow publishing

    tobz committed Apr 16, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    tobz Toby Lawrence
    Copy the full SHA
    8e2e39d View commit details
  6. (cargo-release) version 0.2.0

    tobz committed Apr 16, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    tobz Toby Lawrence
    Copy the full SHA
    8aa249c View commit details
  7. make it publishable pt 2

    tobz committed Apr 16, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    tobz Toby Lawrence
    Copy the full SHA
    d28fa41 View commit details

Commits on May 9, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c91d8f1 View commit details
  2. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    96ab47f View commit details
  3. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    tobz Toby Lawrence
    Copy the full SHA
    ca59173 View commit details
  4. (cargo-release) version 0.12.1

    tobz committed May 9, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    tobz Toby Lawrence
    Copy the full SHA
    f7434bd View commit details

Commits on May 12, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c15c0ed View commit details

Commits on Jun 5, 2023

  1. Update aho-corasick to 1.0.

    tobz committed Jun 5, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    tobz Toby Lawrence
    Copy the full SHA
    a4b2fc1 View commit details

Commits on Jun 13, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    20d207f View commit details
  2. changelog

    tobz committed Jun 13, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    tobz Toby Lawrence
    Copy the full SHA
    c282e44 View commit details

Commits on Jun 22, 2023

  1. Add Borrow impl to KeyName (#381)

    hlbarber authored Jun 22, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c04028c View commit details

Commits on Jul 2, 2023

  1. bump deps + clippy stuff

    tobz committed Jul 2, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    tobz Toby Lawrence
    Copy the full SHA
    61580c0 View commit details
  2. changelog

    tobz committed Jul 2, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    tobz Toby Lawrence
    Copy the full SHA
    4ba145f View commit details
  3. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    tobz Toby Lawrence
    Copy the full SHA
    9d141d1 View commit details
  4. (cargo-release) version 0.15.1

    tobz committed Jul 2, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    tobz Toby Lawrence
    Copy the full SHA
    deead8b View commit details
  5. (cargo-release) version 0.21.1

    tobz committed Jul 2, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    tobz Toby Lawrence
    Copy the full SHA
    0ffcc48 View commit details
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ jobs:
- name: Install Rust ${{ matrix.rust_version }}
run: rustup default ${{ matrix.rust_version }}
- name: Run Tests
run: cargo test --all-features --workspace --exclude=metrics-observer
run: cargo test --all-features --workspace --exclude=metrics-observer -- --test-threads=1
docs:
runs-on: ubuntu-latest
env:
8 changes: 4 additions & 4 deletions metrics-benchmark/Cargo.toml
Original file line number Diff line number Diff line change
@@ -3,15 +3,15 @@ name = "metrics-benchmark"
version = "0.1.1-alpha.5"
authors = ["Toby Lawrence <toby@nuclearfurnace.com>"]
edition = "2018"
rust-version = "1.56.1"
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.11"
portable-atomic = { version = "1", default-features = false, features = ["fallback"] }
metrics = { version = "^0.21", path = "../metrics" }
metrics-util = { version = "0.14", path = "../metrics-util" }
metrics = { version = "0.21", path = "../metrics" }
metrics-util = { version = "0.15", path = "../metrics-util" }
32 changes: 30 additions & 2 deletions metrics-exporter-prometheus/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -8,6 +8,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased] - ReleaseDate

## [0.12.1] - 2023-05-09

### Added

- Support for specifying a username/password for HTTP Basic Authentication when pushing to a Push
Gateway. ([#366](https://github.com/metrics-rs/metrics/pull/366))

## [0.12.0] - 2023-04-16

### Changed

- Bump MSRV to 1.61.0.
@@ -18,14 +27,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Aggregated summaries are now rolling, allowing oldering data points to expire and quantile values
to reflect the recent past rather than the lifetime of a histogram. (#306)
to reflect the recent past rather than the lifetime of a histogram.
([#306](https://github.com/metrics-rs/metrics/pull/306))

They have a default width of three buckets, with each bucket being 20 seconds wide. This means
only the last 60 seconds of a histogram -- in 20 second granularity -- will contribute to the
quantiles emitted.

We'll expose the ability to tune these values in the future.
- Switched to using `portable_atomic` for 64-bit atomics on more architectures. (#313)
- Switched to using `portable_atomic` for 64-bit atomics on more architectures.
([#313](https://github.com/metrics-rs/metrics/pull/313))


## [0.10.0] - 2022-05-30

@@ -37,16 +49,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.9.0] - 2022-03-10

### Added

- New top-level module, `formatting`, which exposes many of the helper methods used to sanitize and
render the actual Prometheus exposition format. ([#285](https://github.com/metrics-rs/metrics/pull/285))

## [0.8.0] - 2022-01-14

### Added

- New builder method, `PrometheusBuilder::install_recorder`, which builds and installs the
recorder and returns a `PrometheusHandle` that can be used to interact with the recorder.

### Changed

- Updated various dependencies in order to properly scope dependencies to only the necessary feature
flags, and thus optimize build times and reduce transitive dependencies.
- Updated to the new handle-based design of `metrics`.
@@ -61,6 +76,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
(name/labels) was recorded.

### Fixed

- Label keys and values, as well as metric descriptions, are now correctly sanitized according to
the Prometheus [data model](https://prometheus.io/docs/concepts/data_model/) and [exposition
format](https://github.com/prometheus/docs/blob/main/content/docs/instrumenting/exposition_formats.md).
@@ -72,38 +88,50 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.7.0] - 2021-12-16

### Changed

- Calling `PrometheusBuilder::install` inside a Tokio runtime will spawn the exporter on that
runtime rather than spawning a new runtime. ([#251](https://github.com/metrics-rs/metrics/pull/251))

## [0.6.1] - 2021-09-16

### Changed

- Simple release to bump dependencies.

## [0.6.0] - 2021-07-15

### Added

- Support for pushing to a Push Gateway. ([#217](https://github.com/metrics-rs/metrics/pull/217))

## [0.5.0] - 2021-05-18

### Added

- `PrometheusBuilder::add_allowed`, which enables the exporter to be configured with a
list of IP addresses or subnets that are allowed to connect. By default, no restrictions
are enforced.

## [0.4.0] - 2021-05-03

### Changed

- Bumped `metrics` dependency to `0.15` and updated the necessary APIs.

## [0.3.0] - 2021-02-02

### Changed

- Bumped `metrics` dependency to `0.14`.

## [0.2.0] - 2021-01-23

### Changed

- Switched from `MetricKind` for `MetricKindMask` for `PrometheusBuilder::idle_timeout`.

## [0.1.0] - 2021-01-22

### Added

- Genesis of the crate.
5 changes: 3 additions & 2 deletions metrics-exporter-prometheus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "metrics-exporter-prometheus"
version = "0.11.0"
version = "0.12.1"
authors = ["Toby Lawrence <toby@nuclearfurnace.com>"]
edition = "2018"
rust-version = "1.61.0"
@@ -24,10 +24,11 @@ push-gateway = ["async-runtime", "hyper/client", "tracing"]

[dependencies]
metrics = { version = "^0.21", path = "../metrics" }
metrics-util = { version = "0.14", path = "../metrics-util", default-features = false, features = ["recency", "registry", "summary"] }
metrics-util = { version = "^0.15", path = "../metrics-util", default-features = false, features = ["recency", "registry", "summary"] }
thiserror = { version = "1", default-features = false }
quanta = { version = "0.11", default-features = false }
indexmap = { version = "1", default-features = false }
base64 = { version = "0.21.0", default-features = false, features = ["std"] }

# Optional
hyper = { version = "0.14", default-features = false, features = ["tcp", "http1"], optional = true }
Original file line number Diff line number Diff line change
@@ -21,7 +21,12 @@ fn main() {
tracing_subscriber::fmt::init();

PrometheusBuilder::new()
.with_push_gateway("http://127.0.0.1:9091/metrics/job/example", Duration::from_secs(10))
.with_push_gateway(
"http://127.0.0.1:9091/metrics/job/example",
Duration::from_secs(10),
None,
None,
)
.expect("push gateway endpoint should be valid")
.idle_timeout(
MetricKindMask::COUNTER | MetricKindMask::HISTOGRAM,
77 changes: 74 additions & 3 deletions metrics-exporter-prometheus/src/builder.rs
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ use hyper::{
use hyper::{
body::{aggregate, Buf},
client::Client,
http::HeaderValue,
Method, Request, Uri,
};

@@ -62,7 +63,12 @@ enum ExporterConfig {
// Run a push gateway task sending to the given `endpoint` after `interval` time has elapsed,
// infinitely.
#[cfg(feature = "push-gateway")]
PushGateway { endpoint: Uri, interval: Duration },
PushGateway {
endpoint: Uri,
interval: Duration,
username: Option<String>,
password: Option<String>,
},

#[allow(dead_code)]
Unconfigured,
@@ -157,6 +163,8 @@ impl PrometheusBuilder {
mut self,
endpoint: T,
interval: Duration,
username: Option<String>,
password: Option<String>,
) -> Result<Self, BuildError>
where
T: AsRef<str>,
@@ -165,6 +173,8 @@ impl PrometheusBuilder {
endpoint: Uri::try_from(endpoint.as_ref())
.map_err(|e| BuildError::InvalidPushGatewayEndpoint(e.to_string()))?,
interval,
username,
password,
};

Ok(self)
@@ -448,16 +458,22 @@ impl PrometheusBuilder {
}

#[cfg(feature = "push-gateway")]
ExporterConfig::PushGateway { endpoint, interval } => {
ExporterConfig::PushGateway { endpoint, interval, username, password } => {
let exporter = async move {
let client = Client::new();
let auth = username.as_ref().map(|name| basic_auth(name, password.as_deref()));

loop {
// Sleep for `interval` amount of time, and then do a push.
tokio::time::sleep(interval).await;

let mut builder = Request::builder();
if let Some(auth) = &auth {
builder = builder.header("authorization", auth.clone());
}

let output = handle.render();
let result = Request::builder()
let result = builder
.method(Method::PUT)
.uri(endpoint.clone())
.body(Body::from(output));
@@ -531,6 +547,25 @@ impl Default for PrometheusBuilder {
}
}

#[cfg(feature = "push-gateway")]
fn basic_auth(username: &str, password: Option<&str>) -> HeaderValue {
use base64::prelude::BASE64_STANDARD;
use base64::write::EncoderWriter;
use std::io::Write;

let mut buf = b"Basic ".to_vec();
{
let mut encoder = EncoderWriter::new(&mut buf, &BASE64_STANDARD);
let _ = write!(encoder, "{username}:");
if let Some(password) = password {
let _ = write!(encoder, "{password}");
}
}
let mut header = HeaderValue::from_bytes(&buf).expect("base64 is always valid HeaderValue");
header.set_sensitive(true);
header
}

#[cfg(test)]
mod tests {
use std::time::Duration;
@@ -993,3 +1028,39 @@ mod tests {
assert_eq!(rendered, expected_counter);
}
}

#[cfg(all(test, feature = "push-gateway"))]
mod push_gateway_tests {
use crate::builder::basic_auth;

#[test]
pub fn test_basic_auth() {
use base64::prelude::BASE64_STANDARD;
use base64::read::DecoderReader;
use std::io::Read;

const BASIC: &str = "Basic ";

// username only
let username = "metrics";
let header = basic_auth(username, None);

let reader = &header.as_ref()[BASIC.len()..];
let mut decoder = DecoderReader::new(reader, &BASE64_STANDARD);
let mut result = Vec::new();
decoder.read_to_end(&mut result).unwrap();
assert_eq!(b"metrics:", &result[..]);
assert!(header.is_sensitive());

// username/password
let password = "123!_@ABC";
let header = basic_auth(username, Some(password));

let reader = &header.as_ref()[BASIC.len()..];
let mut decoder = DecoderReader::new(reader, &BASE64_STANDARD);
let mut result = Vec::new();
decoder.read_to_end(&mut result).unwrap();
assert_eq!(b"metrics:123!_@ABC", &result[..]);
assert!(header.is_sensitive());
}
}
2 changes: 2 additions & 0 deletions metrics-exporter-tcp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased] - ReleaseDate

## [0.8.0] - 2023-04-16

### Changed

- Bump MSRV to 1.61.0.
4 changes: 2 additions & 2 deletions metrics-exporter-tcp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "metrics-exporter-tcp"
version = "0.7.0"
version = "0.8.0"
authors = ["Toby Lawrence <toby@nuclearfurnace.com>"]
edition = "2018"
rust-version = "1.61.0"
@@ -29,7 +29,7 @@ tracing = { version = "0.1", default-features = false, features = ["attributes"]
prost-build = "0.11"

[dev-dependencies]
quanta = "0.10.0"
quanta = "0.11"
tracing = "0.1"
tracing-subscriber = "0.3"
rand = "0.8"
2 changes: 2 additions & 0 deletions metrics-observer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased] - ReleaseDate

## [0.2.0] - 2023-04-16

### Added

- Update hdrhistogram dependency to 7.2
14 changes: 11 additions & 3 deletions metrics-observer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
[package]
name = "metrics-observer"
version = "0.1.1-alpha.2"
version = "0.2.0"
authors = ["Toby Lawrence <toby@nuclearfurnace.com>"]
edition = "2018"
rust-version = "1.61.0"
publish = false

license = "MIT"

description = "Text-based UI for metrics-exporter-tcp."
homepage = "https://github.com/metrics-rs/metrics"
repository = "https://github.com/metrics-rs/metrics"
documentation = "https://docs.rs/metrics"
readme = "README.md"

categories = ["development-tools::debugging"]
keywords = ["metrics", "facade", "macros"]

[dependencies]
metrics = { version = "^0.21", path = "../metrics", default-features = false }
metrics-util = { version = "0.14", path = "../metrics-util", default-features = false, features = ["summary"] }
metrics-util = { version = "^0.15", path = "../metrics-util", default-features = false, features = ["summary"] }
bytes = { version = "1", default-features = false }
crossbeam-channel = { version = "0.5", default-features = false, features = ["std"] }
prost = { version = "0.11", default-features = false }
2 changes: 2 additions & 0 deletions metrics-tracing-context/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased] - ReleaseDate

## [0.14.0] - 2023-04-16

### Changed

- Bump MSRV to 1.61.0.
4 changes: 2 additions & 2 deletions metrics-tracing-context/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "metrics-tracing-context"
version = "0.13.0"
version = "0.14.0"
authors = ["MOZGIII <mike-n@narod.ru>"]
edition = "2018"
rust-version = "1.61.0"
@@ -30,7 +30,7 @@ harness = false
[dependencies]
itoa = { version = "1", default-features = false }
metrics = { version = "^0.21", path = "../metrics" }
metrics-util = { version = "0.14", path = "../metrics-util" }
metrics-util = { version = "^0.15", path = "../metrics-util" }
lockfree-object-pool = { version = "0.1.3", default-features = false }
once_cell = { version = "1", default-features = false, features = ["std"] }
tracing = { version = "0.1.29", default-features = false }
Loading