PrometheusBuilder::install: Build exporter in runtime context
Closes https://github.com/metrics-rs/metrics/issues/122
This commit is contained in:
parent
fbd603582e
commit
01fcc020c7
|
@ -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 || {
|
||||
|
|
Loading…
Reference in New Issue