Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify feature flag code
  • Loading branch information
emschwartz committed May 24, 2023
commit eac1f278adcf435be74ec658c276e0fcd26d270d
23 changes: 11 additions & 12 deletions autometrics/src/tracker/prometheus_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,17 @@ impl TrackMetrics for PrometheusClientTracker {
#[cfg(feature = "exemplars-tracing")]
let exemplar = get_exemplar();

let counter = METRICS.counter.get_or_create(&counter_labels);
#[cfg(feature = "exemplars-tracing")]
counter.inc_by(1, exemplar.clone());
#[cfg(not(feature = "exemplars-tracing"))]
counter.inc();

let histogram = METRICS.histogram.get_or_create(&histogram_labels);
let duration = self.start_time.elapsed().as_secs_f64();
#[cfg(feature = "exemplars-tracing")]
histogram.observe(duration, exemplar);
#[cfg(not(feature = "exemplars-tracing"))]
histogram.observe(duration);
METRICS.counter.get_or_create(&counter_labels).inc_by(
1,
#[cfg(feature = "exemplars-tracing")]
exemplar.clone(),
);

METRICS.histogram.get_or_create(&histogram_labels).observe(
self.start_time.elapsed().as_secs_f64(),
#[cfg(feature = "exemplars-tracing")]
exemplar,
);

if let Some(gauge_labels) = self.gauge_labels {
METRICS.gauge.get_or_create(&gauge_labels).dec();
Expand Down