From 251265a88abc7ab92aae56f7f9ef99686538147c Mon Sep 17 00:00:00 2001 From: Bulat Kurbanov Date: Mon, 6 May 2024 23:34:09 +0200 Subject: [PATCH] Fix --- Cargo.lock | 1 + Cargo.toml | 1 + src/main.rs | 18 +++++++++++++----- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a044094..7fa98a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3878,6 +3878,7 @@ dependencies = [ "once_cell", "prisma-client-rust", "sentry", + "sentry-tracing", "serde", "tokio", "tower-http", diff --git a/Cargo.toml b/Cargo.toml index cd55d8f..7914bd5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,4 +24,5 @@ sentry = { version = "0.32.3", features = ["debug-images"] } 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"] } diff --git a/src/main.rs b/src/main.rs index 1a5c362..822eaef 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,9 @@ pub mod prisma; pub mod views; use sentry::{integrations::debug_images::DebugImagesIntegration, types::Dsn, ClientOptions}; +use sentry_tracing::EventFilter; use tracing::info; +use tracing_subscriber::{filter, layer::SubscriberExt, util::SubscriberInitExt}; use std::{net::SocketAddr, str::FromStr}; @@ -21,11 +23,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(&config::CONFIG.sentry_dsn).unwrap()), default_integrations: false, @@ -35,5 +32,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(); + start_app().await; }