Skip to content

v0.1.9

Compare
Choose a tag to compare
@DenisCarriere DenisCarriere released this 19 Feb 22:25
· 4 commits to main since this release
  • Implement Summary & Histogram
// Summary Metric
// ==============
// Initialize Summary
let mut summary = Summary::from("summary_name");

/// Observe adds a single observation to the summary.
/// Observations are usually positive or zero.
/// Negative observations are accepted but prevent current versions of Prometheus from properly detecting counter resets in the sum of observations
prom_ops.push(summary.observe(88.8));

// Start a timer. Calling the returned function will observe the duration in seconds in the summary.
prom_ops.push(summary.start_timer());

// Histogram Metric
// ==============
// Initialize Summary
let mut histogram = Histogram::from("histogram_name");

/// Observe adds a single observation to the histogram.
/// Observations are usually positive or zero.
/// Negative observations are accepted but prevent current versions of Prometheus from properly detecting counter resets in the sum of observations
prom_ops.push(histogram.observe(88.8));

// Start a timer. Calling the returned function will observe the duration in seconds in the histogram.
prom_ops.push(histogram.start_timer());

// Initialize the metrics for the given combination of labels to zero
prom_ops.push(histogram.zero(HashMap::from([("label1".to_string(), "value1".to_string())])));