Starting impl Sentry and tracing
This commit is contained in:
+33
-2
@@ -1,4 +1,7 @@
|
||||
use crate::{bot::Bot, gitea::WebhookType, state::AppState};
|
||||
use dotenvy::dotenv;
|
||||
use tracing::{info, warn};
|
||||
use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
mod api;
|
||||
mod bot;
|
||||
@@ -10,8 +13,36 @@ mod gitea;
|
||||
mod open_router;
|
||||
mod state;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
fn main() -> anyhow::Result<()> {
|
||||
dotenv().ok();
|
||||
|
||||
tracing_subscriber::registry()
|
||||
.with(fmt::layer())
|
||||
.with(
|
||||
EnvFilter::try_from_default_env() // lit RUST_LOG depuis l'env
|
||||
.unwrap_or_else(|_| EnvFilter::new("info")),
|
||||
)
|
||||
.init();
|
||||
|
||||
if let Ok(sentry_dsn) = env::try_get_env("SENTRY_DSN") {
|
||||
info!("Initialize sentry");
|
||||
|
||||
let _guard = sentry::init((
|
||||
sentry_dsn,
|
||||
sentry::ClientOptions {
|
||||
release: sentry::release_name!(),
|
||||
send_default_pii: true,
|
||||
..Default::default()
|
||||
},
|
||||
));
|
||||
} else {
|
||||
warn!("SENTRY_DSN not set, sentry will not be initialized");
|
||||
}
|
||||
|
||||
tokio::runtime::Runtime::new()?.block_on(run())
|
||||
}
|
||||
|
||||
async fn run() -> anyhow::Result<()> {
|
||||
let config = env::load_config()?;
|
||||
let bot = Bot::new(config.clone())?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user