This commit is contained in:
2024-05-06 23:46:58 +02:00
parent 21ffda8ce4
commit b1143360b4
3 changed files with 15 additions and 5 deletions

1
Cargo.lock generated
View File

@@ -333,6 +333,7 @@ dependencies = [
"axum-prometheus",
"futures-util",
"sentry",
"sentry-tracing",
"tokio",
"tokio-cron-scheduler",
"tokio-util",

View File

@@ -15,6 +15,7 @@ axum-prometheus = "0.6.1"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"]}
sentry-tracing = "0.32.3"
tower-http = { version = "0.5.2", features = ["trace"] }
async-tempfile = "0.5.0"

View File

@@ -11,6 +11,7 @@ use axum::{
use axum_prometheus::PrometheusMetricLayer;
use futures_util::StreamExt;
use sentry::{integrations::debug_images::DebugImagesIntegration, types::Dsn, ClientOptions};
use sentry_tracing::EventFilter;
use std::{io::SeekFrom, net::SocketAddr, str::FromStr};
use tokio::{
fs::{read_dir, remove_dir, remove_file, File},
@@ -21,6 +22,7 @@ use tokio_cron_scheduler::{Job, JobScheduler};
use tokio_util::io::ReaderStream;
use tower_http::trace::{self, TraceLayer};
use tracing::{info, log, Level};
use tracing_subscriber::{filter, layer::SubscriberExt, util::SubscriberInitExt};
async fn remove_temp_files() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let mut dir = read_dir("/tmp/").await?;
@@ -205,11 +207,6 @@ async fn start_app() {
#[tokio::main]
async fn main() {
tracing_subscriber::fmt()
.with_target(false)
.compact()
.init();
let options = ClientOptions {
dsn: Some(
Dsn::from_str(
@@ -225,5 +222,16 @@ async fn main() {
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()];
}