some observability

This commit is contained in:
2023-11-28 18:48:58 +01:00
parent 8366a1d82e
commit 5115265592
3 changed files with 14 additions and 5 deletions

View File

@@ -2,7 +2,7 @@ use std::{sync::Arc, time::Duration};
use async_trait::async_trait;
use async_mutex::Mutex;
use headless_chrome::{Browser, LaunchOptions};
use tracing::{error, info, debug, trace, warn, trace_span};
use tracing::{error, info, debug, trace, warn, trace_span, info_span};
use rocket::{fairing::{Fairing, self}, Rocket, Build, Request, request::{FromRequest, Outcome}, futures::pin_mut, http::Status};
use tokio::time::sleep;
@@ -107,11 +107,14 @@ impl ChromiumCoordinator {
}
pub async fn get_browser(&self) -> std::result::Result<BrowserHolder, ()> {
let span = info_span!("get_browser");
let _enter = span.enter();
loop {
info!("trying to get a browser instance");
match self.try_get_browser().await {
Ok(browser) => return Ok(browser),
Err(_) => {
trace!("all instances of browser are dead... waiting for ");
warn!("all instances of browser are dead... waiting for new instance");
// all instances may be dead ... we must wait for new instance
}
}