This commit is contained in:
2024-05-06 23:29:39 +02:00
parent db95d60b90
commit b1ffd7cb54
3 changed files with 18 additions and 5 deletions

1
Cargo.lock generated
View File

@@ -841,6 +841,7 @@ dependencies = [
"maplit", "maplit",
"reqwest", "reqwest",
"sentry", "sentry",
"sentry-tracing",
"serde", "serde",
"serde_json", "serde_json",
"sql-parse", "sql-parse",

View File

@@ -27,5 +27,7 @@ maplit = "1.0.2"
tracing = "0.1.40" tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"]} tracing-subscriber = { version = "0.3.18", features = ["env-filter"]}
sentry-tracing = "0.32.3"
tower-http = { version = "0.5.2", features = ["trace"] } tower-http = { version = "0.5.2", features = ["trace"] }
dotenv = "0.15.0" dotenv = "0.15.0"

View File

@@ -9,10 +9,14 @@ pub mod utils;
use axum::{http::HeaderMap, routing::post, Router}; use axum::{http::HeaderMap, routing::post, Router};
use dotenv::dotenv; use dotenv::dotenv;
use sentry::{integrations::debug_images::DebugImagesIntegration, types::Dsn, ClientOptions}; use sentry::{integrations::debug_images::DebugImagesIntegration, types::Dsn, ClientOptions};
use sentry_tracing::EventFilter;
use std::{net::SocketAddr, str::FromStr}; use std::{net::SocketAddr, str::FromStr};
use tower_http::trace::{self, TraceLayer}; use tower_http::trace::{self, TraceLayer};
use tracing::log; use tracing::log;
use tracing::Level; use tracing::Level;
use tracing_subscriber::filter;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
use crate::updater::cron_jobs; use crate::updater::cron_jobs;
@@ -57,11 +61,6 @@ async fn start_app() {
async fn main() { async fn main() {
dotenv().ok(); dotenv().ok();
tracing_subscriber::fmt()
.with_target(false)
.compact()
.init();
let options = ClientOptions { let options = ClientOptions {
dsn: Some(Dsn::from_str(&config::CONFIG.sentry_dsn).unwrap()), dsn: Some(Dsn::from_str(&config::CONFIG.sentry_dsn).unwrap()),
default_integrations: false, default_integrations: false,
@@ -71,5 +70,16 @@ async fn main() {
let _guard = sentry::init(options); let _guard = sentry::init(options);
let sentry_layer = sentry_tracing::layer().event_filter(|md| match md.level() {
&tracing::Level::ERROR => EventFilter::Event,
_ => EventFilter::Ignore,
});
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer().with_target(false))
.with(filter::LevelFilter::INFO)
.with(sentry_layer)
.init();
tokio::join![cron_jobs(), start_app()]; tokio::join![cron_jobs(), start_app()];
} }