Install tracing & metrics from within runtime

This commit is contained in:
asonix 2023-10-07 12:29:01 -05:00
parent 3f5bc1d311
commit 760b9d8c59

View file

@ -1,20 +1,28 @@
fn main() -> color_eyre::Result<()> { fn main() -> color_eyre::Result<()> {
let config = pict_rs::PictRsConfiguration::build_default()? run()
.install_tracing()?
.install_metrics()?;
run(config)
} }
#[cfg(feature = "io-uring")] #[cfg(feature = "io-uring")]
fn run(config: pict_rs::PictRsConfiguration) -> color_eyre::Result<()> { fn run() -> color_eyre::Result<()> {
tokio_uring::start(config.run()) tokio_uring::start(async move {
pict_rs::PictRsConfiguration::build_default()?
.install_tracing()?
.install_metrics()?
.run()
.await
})
} }
#[cfg(not(feature = "io-uring"))] #[cfg(not(feature = "io-uring"))]
fn run(config: pict_rs::PictRsConfiguration) -> color_eyre::Result<()> { fn run() -> color_eyre::Result<()> {
tokio::runtime::Builder::new_multi_thread() tokio::runtime::Builder::new_multi_thread()
.enable_all() .enable_all()
.build()? .build()?
.block_on(config.run()) .block_on(async move {
pict_rs::PictRsConfiguration::build_default()?
.install_tracing()?
.install_metrics()?
.run_on_localset()
.await
})
} }