Skip to content

Commit

Permalink
feat: enable sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
m1sk9 authored and kawaemon committed Jan 5, 2024
1 parent 220820c commit c8117db
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ run apt-get update \
wget unzip clang \
cmake llvm nettle-dev \
pkg-config \
libssl-dev ca-certificates \
&& rm -rf /var/lib/apt/lists/*

copy --from=plan /src/download_font.sh .
Expand Down
39 changes: 33 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(warnings)]

mod bot;
mod client;
mod db;
Expand All @@ -20,14 +18,43 @@ assert_one_feature!("discord_client", "console_client");
assert_one_feature!("mongo_db", "memory_db");
assert_one_feature!("plot_plotters", "plot_matplotlib");

#[tokio::main]
async fn main() -> Result<()> {
fn setup_sentry() -> Option<ClientInitGuard> {
let Ok(sentry_dsn) = env_var("SENTRY_DSN") else {
#[cfg(not(debug_assertions))]
panic!("SENTRY_DSN is not set");
#[cfg(debug_assertions)]
return None;
};

let guard = sentry::init((
sentry_dsn,
sentry::ClientOptions {
release: sentry::release_name!(),
..Default::default()
},
));

tracing::info!("sentry initialized");

Some(guard)
}

fn main() -> Result<()> {
dotenv::dotenv().ok();

let use_ansi = env_var("NO_COLOR").is_err();

tracing_subscriber::fmt().with_ansi(use_ansi).init();

let _guard = setup_sentry();

tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap()
.block_on(async_main())
}

async fn async_main() -> Result<()> {
#[cfg(feature = "memory_db")]
let local_db = crate::db::mem::MemoryDB::new();
#[cfg(feature = "memory_db")]
Expand Down Expand Up @@ -95,4 +122,4 @@ macro_rules! assert_one_feature {
};
}

use assert_one_feature;
use {assert_one_feature, sentry::ClientInitGuard};

0 comments on commit c8117db

Please sign in to comment.