Skip to content

Commit

Permalink
move
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy committed Oct 19, 2024
1 parent 06df0d0 commit f8bdbe1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions crates/metrics/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use hyper::service::{make_service_fn, service_fn};
use hyper::{Body, Request, Response};

use crate::exporters::Exporter;
use crate::process::{collect_memory_stats, describe_memory_stats};
use crate::{Error, Report};

/// A helper trait for defining the type for hooks that are called when the metrics are being
Expand Down Expand Up @@ -39,9 +38,7 @@ where
{
/// Creates a new metrics server using the given exporter.
pub fn new(exporter: MetricsExporter) -> Self {
describe_memory_stats();
let hooks: Hooks = vec![Box::new(collect_memory_stats)];
Self { exporter, hooks }
Self { exporter, hooks: Vec::new() }
}

Check warning on line 42 in crates/metrics/src/server.rs

View check run for this annotation

Codecov / codecov/patch

crates/metrics/src/server.rs#L40-L42

Added lines #L40 - L42 were not covered by tests

/// Add new metrics reporter to the server.
Expand All @@ -56,9 +53,16 @@ where
}

Check warning on line 53 in crates/metrics/src/server.rs

View check run for this annotation

Codecov / codecov/patch

crates/metrics/src/server.rs#L45-L53

Added lines #L45 - L53 were not covered by tests

pub fn with_process_metrics(mut self) -> Self {
use crate::process::{collect_memory_stats, describe_memory_stats};

let process = metrics_process::Collector::default();
process.describe();
self.hooks.push(Box::new(move || process.collect()) as BoxedHook);
describe_memory_stats();

let hooks: Hooks =
vec![Box::new(collect_memory_stats), Box::new(move || process.collect())];

self.hooks.extend(hooks);
self
}

Check warning on line 67 in crates/metrics/src/server.rs

View check run for this annotation

Codecov / codecov/patch

crates/metrics/src/server.rs#L55-L67

Added lines #L55 - L67 were not covered by tests

Expand Down

0 comments on commit f8bdbe1

Please sign in to comment.