Skip to content

Commit

Permalink
PrometheusBuilder::install: Build exporter in runtime context
Browse files Browse the repository at this point in the history
  • Loading branch information
str4d committed Nov 11, 2020
1 parent c893817 commit e54ac2b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions metrics-exporter-prometheus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,14 +443,14 @@ impl PrometheusBuilder {
/// installing the recorder as the global recorder.
#[cfg(feature = "tokio-exporter")]
pub fn install(self) -> Result<(), Error> {
let (recorder, exporter) = self.build_with_exporter()?;
metrics::set_boxed_recorder(Box::new(recorder))?;

let mut runtime = runtime::Builder::new()
.basic_scheduler()
.enable_all()
.build()?;

let (recorder, exporter) = runtime.enter(|| self.build_with_exporter())?;
metrics::set_boxed_recorder(Box::new(recorder))?;

thread::Builder::new()
.name("metrics-exporter-prometheus-http".to_string())
.spawn(move || {
Expand Down

0 comments on commit e54ac2b

Please sign in to comment.