Skip to content

Commit

Permalink
fix: comment out more metric-instrumentation code
Browse files Browse the repository at this point in the history
Signed-off-by: 0x009922 <[email protected]>
  • Loading branch information
0x009922 committed Oct 9, 2024
1 parent 76b4afd commit a7abadb
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions crates/iroha_telemetry_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,26 +244,26 @@ fn impl_metrics(
}
};

#[cfg(feature = "metric-instrumentation")]
{
let (totals, successes, times) = write_metrics(metric_arg_ident, specs);
return quote!(
#(#attrs)* #vis #sig {
let _closure = || #block;
let started_at = std::time::Instant::now();

#totals
let res = _closure();

#times
if let Ok(_) = res {
#successes
};
res
});
};
// #[cfg(feature = "metric-instrumentation")]
// {
// let (totals, successes, times) = write_metrics(metric_arg_ident, specs);
// quote!(
// #(#attrs)* #vis #sig {
// let closure = || #block;
// let started_at = std::time::Instant::now();
//
// #totals
// let res = closure();
//
// #times
// if let Ok(_) = res {
// #successes
// };
// res
// })
// }

#[cfg(not(feature = "metric-instrumentation"))]
// #[cfg(not(feature = "metric-instrumentation"))]
quote!(
#(#attrs)* #vis #sig {
#block
Expand All @@ -279,19 +279,19 @@ fn write_metrics(
) -> (TokenStream, TokenStream, TokenStream) {
let inc_metric = |spec: &MetricSpec, kind: &str| {
quote!(
// #metric_arg_ident
// .metrics
// .isi
// .with_label_values( &[#spec, #kind ]).inc();
#metric_arg_ident
.metrics
.isi
.with_label_values( &[#spec, #kind ]).inc();
)
};
let track_time = |spec: &MetricSpec| {
quote!(
// #metric_arg_ident
// .metrics
// .isi_times
// .with_label_values( &[#spec])
// .observe(started_at.elapsed().as_millis() as f64);
#metric_arg_ident
.metrics
.isi_times
.with_label_values( &[#spec])
.observe(started_at.elapsed().as_millis() as f64);
)
};
let totals: TokenStream = specs
Expand Down

0 comments on commit a7abadb

Please sign in to comment.