Skip to content

Commit

Permalink
reduce allocations in metrics.rs (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheIronBorn authored Nov 26, 2024
1 parent f241c32 commit 7331dd6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/core/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl PrometheusRegistry {
impl Display for PrometheusRegistry {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
for (i, (_, r)) in self.groups.iter().enumerate() {
f.write_str(&format!("{r}"))?;
write!(f, "{r}")?;
f.write_str("\n")?;

if i < self.groups.len() - 1 {
Expand Down Expand Up @@ -131,7 +131,7 @@ impl Display for LabelledMetric {

let num_labels = self.labels.len();
for (i, label) in self.labels.iter().enumerate() {
f.write_str(&format!("{}=\"{}\"", label.key, label.val))?;
write!(f, "{}=\"{}\"", label.key, label.val)?;

if i < num_labels - 1 {
f.write_str(",")?;
Expand Down Expand Up @@ -191,9 +191,9 @@ impl Display for PrometheusGroup {
for m in &self.metrics {
f.write_str("\n")?;
f.write_str(&self.name)?;
f.write_str(&format!("{m}"))?;
write!(f, "{m}")?;
f.write_str(" ")?;
f.write_str(&format!("{timestamp}"))?;
write!(f, "{timestamp}")?;
}

Ok(())
Expand Down

0 comments on commit 7331dd6

Please sign in to comment.