Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
plietar committed Aug 28, 2024
1 parent 9f48ed7 commit dd6b97d
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,30 +213,30 @@ impl HttpMetrics {
}
}

/// Render the metrics from a `prometheus::Registry` into an HTTP response.
pub fn render(registry: Registry) -> impl IntoResponse {
let mut buffer = vec![];
let encoder = prometheus::TextEncoder::new();
let metrics = registry.gather();
encoder.encode(&metrics, &mut buffer).unwrap();

let headers = [(axum::http::header::CONTENT_TYPE, prometheus::TEXT_FORMAT)];
(headers, buffer)
}

#[cfg(target_os = "linux")]
pub fn register_process_metrics(registry: &Registry) -> prometheus::Result<()> {
use prometheus::process_collector::ProcessCollector;
registry.register(Box::new(ProcessCollector::for_self()))
}

#[cfg(not(target_os = "linux"))]
pub fn register_process_metrics(registry: &Registry) -> prometheus::Result<()> {
pub fn register_process_metrics(_registry: &Registry) -> prometheus::Result<()> {
// The prometheus crate doesn't offer a process collector on platforms other
// than Linux
Ok(())
}

/// Render the metrics from a `prometheus::Registry` into an HTTP response.
pub fn render(registry: Registry) -> impl IntoResponse {
let mut buffer = vec![];
let encoder = prometheus::TextEncoder::new();
let metrics = registry.gather();
encoder.encode(&metrics, &mut buffer).unwrap();

let headers = [(axum::http::header::CONTENT_TYPE, prometheus::TEXT_FORMAT)];
(headers, buffer)
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit dd6b97d

Please sign in to comment.