Skip to content

Commit

Permalink
Enable metrics in microbenchmarks (#1463)
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai authored Feb 8, 2024
1 parent 8142031 commit bd7fbe8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion shotover/benches/benches/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use shotover::transforms::throttling::RequestThrottlingConfig;
use shotover::transforms::{TransformConfig, Wrapper};

fn criterion_benchmark(c: &mut Criterion) {
super::init();
crate::init();
let rt = tokio::runtime::Runtime::new().unwrap();
let mut group = c.benchmark_group("transform");
group.noise_threshold(0.2);
Expand Down
1 change: 1 addition & 0 deletions shotover/benches/benches/codec/cassandra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use shotover::message::Message;
use tokio_util::codec::{Decoder, Encoder};

fn criterion_benchmark(c: &mut Criterion) {
crate::init();
let mut group = c.benchmark_group("cassandra_codec");
group.noise_threshold(0.2);

Expand Down
1 change: 1 addition & 0 deletions shotover/benches/benches/codec/kafka.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const KAFKA_REQUESTS: &[(&[u8], &str)] = &[
];

fn criterion_benchmark(c: &mut Criterion) {
crate::init();
let mut group = c.benchmark_group("kafka_codec");
group.noise_threshold(0.2);

Expand Down
4 changes: 4 additions & 0 deletions shotover/benches/benches/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
use criterion::criterion_main;
use metrics_exporter_prometheus::PrometheusBuilder;

mod chain;
mod codec;

fn init() {
std::env::set_var("RUST_BACKTRACE", "1");
std::env::set_var("RUST_LIB_BACKTRACE", "0");

let recorder = PrometheusBuilder::new().build_recorder();
metrics::set_boxed_recorder(Box::new(recorder)).ok();
}

criterion_main!(
Expand Down

0 comments on commit bd7fbe8

Please sign in to comment.