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.
|
/// installing the recorder as the global recorder.
|
||||||
#[cfg(feature = "tokio-exporter")]
|
#[cfg(feature = "tokio-exporter")]
|
||||||
pub fn install(self) -> Result<(), Error> {
|
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()
|
let mut runtime = runtime::Builder::new()
|
||||||
.basic_scheduler()
|
.basic_scheduler()
|
||||||
.enable_all()
|
.enable_all()
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
|
let (recorder, exporter) = runtime.enter(|| self.build_with_exporter())?;
|
||||||
|
metrics::set_boxed_recorder(Box::new(recorder))?;
|
||||||
|
|
||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
.name("metrics-exporter-prometheus-http".to_string())
|
.name("metrics-exporter-prometheus-http".to_string())
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
|
|
Loading…
Reference in New Issue