Skip to content

Commit

Permalink
GH-62 # Bump API dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo-C committed Jul 2, 2024
1 parent 31b5a40 commit 5f84cc9
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 127 deletions.
140 changes: 16 additions & 124 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ lazy_static = "1.4"
regex = "1.7"
csv = "1.3"
openssl = { version = "~0.10.55", features = ["vendored"] } # Required for sentry
sentry = "0.32"
sentry = "^0.34"
rocket-sentry = "0.18"
redis = "0.25"
log = "0.4"
Expand Down
28 changes: 26 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::sync::Arc;
use sentry::TransactionContext;
use ::rocket_sentry::RocketSentry;
use env_logger::Env;
use jarm_online::build_rocket;
Expand Down Expand Up @@ -27,9 +29,31 @@ impl Fairing for CORS {
#[rocket::main]
async fn main() -> Result<(), rocket::Error> {
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
build_rocket()
let rocket_instance = build_rocket();
// Get the default configured sample rate from `Rocket.toml`
let default_rate = rocket_instance
.figment()
.extract_inner::<f32>("sentry_traces_sample_rate")
.unwrap_or(1.);
let traces_sampler = move |ctx: &TransactionContext| -> f32 {
match ctx.name() {
"GET /last-scans" => {
if default_rate == 0. {
0. // Allow to disable Sentry completely
} else {
0.0001
}
},
_ => default_rate,
}
};
let rocket_sentry = RocketSentry::builder()
.traces_sampler(Arc::new(traces_sampler))
.build();

rocket_instance
.attach(CORS)
.attach(RocketSentry::fairing())
.attach(rocket_sentry)
.launch()
.await?;
Ok(())
Expand Down

0 comments on commit 5f84cc9

Please sign in to comment.