Skip to content

Commit

Permalink
Refactor HTTP metrics. (#1249)
Browse files Browse the repository at this point in the history
This PR refactors how response for the HTTP metrics endpoint is being
assembled. It uses a very thin layer on top of the bare Prometheus
protocol instead of manually writing all the content.

Ideally, this doesn’t change any of the metrics. It does, however,
slightly change the formatting.
  • Loading branch information
partim authored Jan 27, 2025
1 parent b4a7508 commit 068bd6a
Show file tree
Hide file tree
Showing 4 changed files with 629 additions and 551 deletions.
20 changes: 13 additions & 7 deletions src/commons/api/ca.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//! Common data types for Certificate Authorities, defined here so that the
//! CLI can have access without needing to depend on the full krill_ca module.
use std::{fmt, ops, str};
use std::collections::hash_map;
use std::collections::HashMap;
use std::ops::{self};
use std::str::FromStr;
use std::sync::Arc;
use std::{fmt, str};

use base64::engine::general_purpose::STANDARD as BASE64_ENGINE;
use base64::engine::Engine as _;
Expand Down Expand Up @@ -962,9 +962,7 @@ impl ParentStatuses {
self.0.get(parent)
}

pub fn iter(
&self,
) -> impl Iterator<Item = (&ParentHandle, &ParentStatus)> {
pub fn iter(&self) -> hash_map::Iter<ParentHandle, ParentStatus> {
self.0.iter()
}

Expand Down Expand Up @@ -1062,14 +1060,22 @@ impl ParentStatuses {

impl IntoIterator for ParentStatuses {
type Item = (ParentHandle, ParentStatus);
type IntoIter =
std::collections::hash_map::IntoIter<ParentHandle, ParentStatus>;
type IntoIter = hash_map::IntoIter<ParentHandle, ParentStatus>;

fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
}
}

impl<'a> IntoIterator for &'a ParentStatuses {
type Item = (&'a ParentHandle, &'a ParentStatus);
type IntoIter = hash_map::Iter<'a, ParentHandle, ParentStatus>;

fn into_iter(self) -> Self::IntoIter {
self.0.iter()
}
}

impl fmt::Display for ParentStatuses {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for (parent, status) in self.0.iter() {
Expand Down
Loading

0 comments on commit 068bd6a

Please sign in to comment.