Skip to content

Commit

Permalink
add support for OpenMetrics message format
Browse files Browse the repository at this point in the history
This commit adds support for the OpenMetrics message format[1] which is
equivalent to the message format of Prometheus. Its advantage is to be
easily human readable as well as consumable by time series databases.

Lastly it's possible to display results directly within the GitLab CI.

It's now possible to pass 'openmetrics' as a message format, an example
is shown below:

criterion_benchmark_result_ns{id="address_scan",confidence="estimate",input_size="4",aggregation="slope"} 33811.02693018697
criterion_benchmark_result_ns{id="address_scan",confidence="upper_bound",input_size="4",aggregation="slope"} 35170.884432780265
criterion_benchmark_result_ns{id="address_scan",confidence="lower_bound",input_size="4",aggregation="slope"} 32402.287415202973
criterion_benchmark_info{id="address_scan",input_size="4",report_directory="/path/criterion/reports/address_scan/4"} 1

[1]: https://openmetrics.io

Signed-off-by: Kevin Becker <[email protected]>
Signed-off-by: Paul Spooren <[email protected]>
  • Loading branch information
Paul Spooren committed Jul 19, 2022
1 parent c400393 commit b736ea2
Show file tree
Hide file tree
Showing 5 changed files with 414 additions and 258 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

# [Unreleased]
### Added
- New message output format for [OpenMetrics](https://openmetrics.io).

## [1.1.0] - 2021-07-28
### Fixed
Expand Down Expand Up @@ -66,4 +68,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
[1.0.0]: https://github.com/bheisler/cargo-criterion/compare/1.0.0-alpha3...1.0.0
[1.0.1]: https://github.com/bheisler/cargo-criterion/compare/1.0.0-alpha3...1.0.1
[1.0.1]: https://github.com/bheisler/cargo-criterion/compare/1.0.1...1.1.0
[Unreleased]: https://github.com/bheisler/cargo-criterion/compare/1.1.0...HEAD
[Unreleased]: https://github.com/bheisler/cargo-criterion/compare/1.1.0...HEAD
6 changes: 4 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,13 @@ impl PlottingBackend {
#[derive(Debug)]
pub enum MessageFormat {
Json,
OpenMetrics,
}
impl MessageFormat {
fn from_str(s: &str) -> MessageFormat {
match s {
"json" => MessageFormat::Json,
"openmetrics" => MessageFormat::OpenMetrics,
other => panic!("Unknown message format: {}", other),
}
}
Expand Down Expand Up @@ -422,10 +424,10 @@ bencher: Emulates the output format of the bencher crate and nightly-only libtes
.arg(Arg::with_name("message-format")
.long("message-format")
.takes_value(true)
.possible_values(&["json"])
.possible_values(&["json", "openmetrics"])
.help("If set, machine-readable output of the requested format will be printed to stdout.")
.long_help(
"Change the machine-readable output format. Possible values are [json].
"Change the machine-readable output format. Possible values are [json, openmetrics].
Machine-readable information on the benchmarks will be printed in the requested format to stdout.
All of cargo-criterion's other output will be printed to stderr.
Expand Down
Loading

0 comments on commit b736ea2

Please sign in to comment.