From 0a1e374f2b575f92ff49b4abcc4013db169bcd87 Mon Sep 17 00:00:00 2001 From: Pavel Kirilin Date: Tue, 21 Nov 2023 01:00:10 +0100 Subject: [PATCH 1/6] Added sentry integration. Signed-off-by: Pavel Kirilin --- Cargo.lock | 265 +++++++++++++++++- Cargo.toml | 9 + src/config.rs | 16 +- src/data_storage/impls/file_storage.rs | 2 +- src/data_storage/impls/s3_hybrid.rs | 2 +- src/data_storage/mod.rs | 2 +- src/errors.rs | 4 +- src/info_storages/base.rs | 4 +- src/info_storages/impls/file_info_storage.rs | 2 +- src/info_storages/impls/redis_info_storage.rs | 2 +- src/info_storages/mod.rs | 2 +- src/main.rs | 60 ++-- src/notifiers/impls/amqp_notifier.rs | 4 +- src/notifiers/impls/dir_notifier.rs | 2 +- src/notifiers/impls/file_notifier.rs | 2 +- src/notifiers/impls/http_notifier.rs | 2 +- src/notifiers/manager.rs | 2 +- src/notifiers/mod.rs | 2 +- src/server/mod.rs | 16 +- src/state.rs | 2 +- src/utils/hashes.rs | 6 +- src/utils/lapin_pool.rs | 2 + 22 files changed, 342 insertions(+), 68 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 443b531..2afb6c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,6 +28,15 @@ dependencies = [ "version_check", ] +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + [[package]] name = "amq-protocol" version = "7.1.2" @@ -648,6 +657,16 @@ dependencies = [ "typenum", ] +[[package]] +name = "debugid" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" +dependencies = [ + "serde", + "uuid", +] + [[package]] name = "deranged" version = "0.3.9" @@ -814,6 +833,18 @@ dependencies = [ "log", ] +[[package]] +name = "findshlibs" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40b9e59cd0f7e0806cca4be089683ecb6434e602038df21fe6bf6711b2f07f64" +dependencies = [ + "cc", + "lazy_static", + "libc", + "winapi", +] + [[package]] name = "flume" version = "0.10.14" @@ -1067,6 +1098,17 @@ dependencies = [ "digest", ] +[[package]] +name = "hostname" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" +dependencies = [ + "libc", + "match_cfg", + "winapi", +] + [[package]] name = "http" version = "0.2.11" @@ -1383,6 +1425,12 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "match_cfg" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" + [[package]] name = "matchit" version = "0.7.2" @@ -1648,6 +1696,17 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "os_info" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "006e42d5b888366f1880eda20371fedde764ed2213dc8496f49622fa0c99cd5e" +dependencies = [ + "log", + "serde", + "winapi", +] + [[package]] name = "overload" version = "0.1.1" @@ -1926,6 +1985,35 @@ dependencies = [ "thiserror", ] +[[package]] +name = "regex" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + [[package]] name = "reqwest" version = "0.11.22" @@ -2035,6 +2123,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + [[package]] name = "rustix" version = "0.37.27" @@ -2143,6 +2240,9 @@ dependencies = [ "reqwest", "rust-s3", "rustc-hash", + "sentry", + "sentry-tower", + "sentry-tracing", "serde", "serde_json", "sha1", @@ -2153,6 +2253,8 @@ dependencies = [ "tokio-util", "tower", "tower-http", + "tracing", + "tracing-subscriber", "uuid", "wildmatch", ] @@ -2234,6 +2336,134 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" + +[[package]] +name = "sentry" +version = "0.31.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce4b57f1b521f674df7a1d200be8ff5d74e3712020ee25b553146657b5377d5" +dependencies = [ + "httpdate", + "native-tls", + "reqwest", + "sentry-backtrace", + "sentry-contexts", + "sentry-core", + "sentry-debug-images", + "sentry-panic", + "sentry-tracing", + "tokio", + "ureq", +] + +[[package]] +name = "sentry-backtrace" +version = "0.31.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58cc8d4e04a73de8f718dc703943666d03f25d3e9e4d0fb271ca0b8c76dfa00e" +dependencies = [ + "backtrace", + "once_cell", + "regex", + "sentry-core", +] + +[[package]] +name = "sentry-contexts" +version = "0.31.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6436c1bad22cdeb02179ea8ef116ffc217797c028927def303bc593d9320c0d1" +dependencies = [ + "hostname", + "libc", + "os_info", + "rustc_version", + "sentry-core", + "uname", +] + +[[package]] +name = "sentry-core" +version = "0.31.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901f761681f97db3db836ef9e094acdd8756c40215326c194201941947164ef1" +dependencies = [ + "once_cell", + "rand", + "sentry-types", + "serde", + "serde_json", +] + +[[package]] +name = "sentry-debug-images" +version = "0.31.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afdb263e73d22f39946f6022ed455b7561b22ff5553aca9be3c6a047fa39c328" +dependencies = [ + "findshlibs", + "once_cell", + "sentry-core", +] + +[[package]] +name = "sentry-panic" +version = "0.31.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74fbf1c163f8b6a9d05912e1b272afa27c652e8b47ea60cb9a57ad5e481eea99" +dependencies = [ + "sentry-backtrace", + "sentry-core", +] + +[[package]] +name = "sentry-tower" +version = "0.31.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88e782e369edac4adfc5bf528b27577270bc3e7023c388ebad9db08e1d56b30b" +dependencies = [ + "http", + "pin-project", + "sentry-core", + "tower-layer", + "tower-service", + "url", +] + +[[package]] +name = "sentry-tracing" +version = "0.31.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82eabcab0a047040befd44599a1da73d3adb228ff53b5ed9795ae04535577704" +dependencies = [ + "sentry-backtrace", + "sentry-core", + "tracing-core", + "tracing-subscriber", +] + +[[package]] +name = "sentry-types" +version = "0.31.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da956cca56e0101998c8688bc65ce1a96f00673a0e58e663664023d4c7911e82" +dependencies = [ + "debugid", + "hex", + "rand", + "serde", + "serde_json", + "thiserror", + "time 0.3.30", + "url", + "uuid", +] + [[package]] name = "serde" version = "1.0.192" @@ -2726,11 +2956,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "log", "pin-project-lite", "tracing-attributes", @@ -2750,9 +2979,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", "valuable", @@ -2776,9 +3005,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "nu-ansi-term", + "parking_lot", "sharded-slab", "smallvec", "thread_local", + "time 0.3.30", "tracing-core", "tracing-log", ] @@ -2795,6 +3026,15 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "uname" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b72f89f0ca32e4db1c04e2a72f5345d59796d4866a1ee0609084569f73683dc8" +dependencies = [ + "libc", +] + [[package]] name = "unicase" version = "2.7.0" @@ -2831,6 +3071,19 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" +[[package]] +name = "ureq" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7830e33f6e25723d41a63f77e434159dad02919f18f55a512b5f16f3b1d77138" +dependencies = [ + "base64 0.21.5", + "log", + "native-tls", + "once_cell", + "url", +] + [[package]] name = "url" version = "2.4.1" @@ -2840,6 +3093,7 @@ dependencies = [ "form_urlencoded", "idna", "percent-encoding", + "serde", ] [[package]] @@ -2855,6 +3109,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" dependencies = [ "getrandom", + "serde", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 534287e..effc833 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,6 +50,15 @@ lapin = "2.3.1" tower-http = { version = "0.4.4", features = ["cors"] } http = "^0.2" wildmatch = "2.1.1" +tracing = "0.1.40" +sentry = { version = "0.31.8" } +sentry-tracing = "0.31.8" +tracing-subscriber = { version = "0.3.18", features = [ + "smallvec", + "parking_lot", + "time", +] } +sentry-tower = { version = "0.31.8", features = ["http"] } [profile.release] diff --git a/src/config.rs b/src/config.rs index 0c1d79d..143d79a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -276,6 +276,17 @@ pub struct NotificationConfig { pub amqp_hook_opts: AMQPHooksOptions, } +#[derive(Parser, Clone, Debug)] +pub struct SentryConfig { + /// Sentry DSN. + #[arg(long, env = "RUSTUS_SENTRY_DSN")] + pub sentry_dsn: Option, + + /// Sentry sample rate. + #[arg(long, env = "RUSTUS_SENTRY_SAMPLE_RATE")] + pub sentry_sample_rate: Option, +} + #[derive(Parser, Clone, Debug)] #[command(author, version, about, long_about = None)] #[allow(clippy::struct_excessive_bools)] @@ -290,7 +301,7 @@ pub struct Config { /// Log level for the server. #[arg(long, default_value = "INFO", env = "RUSTUS_LOG_LEVEL")] - pub log_level: log::LevelFilter, + pub log_level: tracing::level_filters::LevelFilter, /// Number of worker threads for the server. /// @@ -374,6 +385,9 @@ pub struct Config { #[command(flatten)] pub notification_config: NotificationConfig, + + #[command(flatten)] + pub sentry_config: SentryConfig, } impl Config { diff --git a/src/data_storage/impls/file_storage.rs b/src/data_storage/impls/file_storage.rs index 55ff30a..52667c5 100644 --- a/src/data_storage/impls/file_storage.rs +++ b/src/data_storage/impls/file_storage.rs @@ -15,7 +15,7 @@ use crate::{ utils::{dir_struct::substr_now, headers::HeaderMapExt}, }; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct FileStorage { data_dir: PathBuf, dir_struct: String, diff --git a/src/data_storage/impls/s3_hybrid.rs b/src/data_storage/impls/s3_hybrid.rs index d6e7821..6b5ef1e 100644 --- a/src/data_storage/impls/s3_hybrid.rs +++ b/src/data_storage/impls/s3_hybrid.rs @@ -26,7 +26,7 @@ use super::file_storage::FileStorage; /// complete, it uploads file to S3. /// /// It's not intended to use this storage for large files. -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct S3HybridStorage { bucket: Bucket, local_storage: FileStorage, diff --git a/src/data_storage/mod.rs b/src/data_storage/mod.rs index 6007bcd..712dac5 100644 --- a/src/data_storage/mod.rs +++ b/src/data_storage/mod.rs @@ -21,7 +21,7 @@ pub enum AvailableStorages { from_str!(AvailableStorages, "storages"); -#[derive(Clone)] +#[derive(Clone, Debug)] pub enum DataStorageImpl { File(FileStorage), S3Hybrid(S3HybridStorage), diff --git a/src/errors.rs b/src/errors.rs index 7fdd2b7..b75e93b 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -100,8 +100,10 @@ impl RustusError { impl IntoResponse for RustusError { fn into_response(self) -> axum::response::Response { - log::error!("{self}"); let status_code = self.get_status_code(); + if status_code != StatusCode::NOT_FOUND { + log::error!("{self}"); + } match self { RustusError::HTTPHookError(_, proxy_response, content_type) => { axum::response::IntoResponse::into_response(( diff --git a/src/info_storages/base.rs b/src/info_storages/base.rs index 3e480da..c285f61 100644 --- a/src/info_storages/base.rs +++ b/src/info_storages/base.rs @@ -1,9 +1,11 @@ +use std::fmt::Debug; + use crate::{errors::RustusResult, models::file_info::FileInfo}; /// Trait for every info storage. /// /// This trait defines required functions /// for building your own info storage. -pub trait InfoStorage { +pub trait InfoStorage: Clone + Debug { /// Prepare storage for storing files. /// /// In this function you can prepare diff --git a/src/info_storages/impls/file_info_storage.rs b/src/info_storages/impls/file_info_storage.rs index 8d44c61..fb19085 100644 --- a/src/info_storages/impls/file_info_storage.rs +++ b/src/info_storages/impls/file_info_storage.rs @@ -9,7 +9,7 @@ use crate::{ utils::result::MonadLogger, }; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct FileInfoStorage { info_dir: PathBuf, } diff --git a/src/info_storages/impls/redis_info_storage.rs b/src/info_storages/impls/redis_info_storage.rs index 8d351f6..20c5926 100644 --- a/src/info_storages/impls/redis_info_storage.rs +++ b/src/info_storages/impls/redis_info_storage.rs @@ -35,7 +35,7 @@ impl Manager for RedisConnectionManager { } } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct RedisStorage { pool: Pool, expiration: Option, diff --git a/src/info_storages/mod.rs b/src/info_storages/mod.rs index 8015583..fe20da1 100644 --- a/src/info_storages/mod.rs +++ b/src/info_storages/mod.rs @@ -17,7 +17,7 @@ pub enum AvailableInfoStorages { from_str!(AvailableInfoStorages, "info storage"); -#[derive(Clone)] +#[derive(Clone, Debug)] pub enum InfoStorageImpl { Redis(RedisStorage), File(FileInfoStorage), diff --git a/src/main.rs b/src/main.rs index 5abed8f..fe63454 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,10 @@ #![allow(async_fn_in_trait)] +use std::str::FromStr; + use errors::RustusResult; -use fern::{ - colors::{Color, ColoredLevelConfig}, - Dispatch, -}; -use log::LevelFilter; +use sentry::types::Dsn; +use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; pub mod config; pub mod data_storage; @@ -21,31 +20,6 @@ pub mod utils; #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; -#[cfg_attr(coverage, no_coverage)] -fn setup_logging(app_config: &config::Config) -> RustusResult<()> { - let colors = ColoredLevelConfig::new() - // use builder methods - .info(Color::Green) - .warn(Color::Yellow) - .debug(Color::BrightCyan) - .error(Color::BrightRed) - .trace(Color::Blue); - - Dispatch::new() - .level(app_config.log_level) - .level_for("rbatis", LevelFilter::Error) - .chain(std::io::stdout()) - .format(move |out, message, record| { - out.finish(format_args!( - "{}[{}] {}", - chrono::Local::now().format("[%Y-%m-%d][%H:%M:%S%:z]"), - colors.color(record.level()), - message - )); - }) - .apply()?; - Ok(()) -} #[cfg_attr(coverage, no_coverage)] fn greeting(app_conf: &config::Config) { let extensions = app_conf @@ -74,7 +48,31 @@ fn greeting(app_conf: &config::Config) { fn main() -> RustusResult<()> { let args = config::Config::parse(); - setup_logging(&args)?; + let mut _guard = None; + if let Some(sentry_dsn) = &args.sentry_config.sentry_dsn { + _guard = Some(sentry::init(sentry::ClientOptions { + dsn: Dsn::from_str(sentry_dsn.as_str()).ok(), + // Enable capturing of traces; set this a to lower value in production: + traces_sample_rate: 1.0, + ..sentry::ClientOptions::default() + })); + } + + tracing_subscriber::registry() + .with(tracing_subscriber::filter::filter_fn(move |a| { + a.level() <= &args.log_level + })) + .with( + tracing_subscriber::fmt::layer() + .with_level(true) + .with_file(false) + .with_line_number(false) + .with_target(false) + .compact(), + ) + .with(sentry_tracing::layer()) + .init(); + greeting(&args); let mut builder = if Some(1) == args.workers { tokio::runtime::Builder::new_current_thread() diff --git a/src/notifiers/impls/amqp_notifier.rs b/src/notifiers/impls/amqp_notifier.rs index b2907d4..6add534 100644 --- a/src/notifiers/impls/amqp_notifier.rs +++ b/src/notifiers/impls/amqp_notifier.rs @@ -20,7 +20,7 @@ use crate::{ }; #[allow(clippy::struct_excessive_bools)] -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct DeclareOptions { pub declare_exchange: bool, pub durable_exchange: bool, @@ -28,7 +28,7 @@ pub struct DeclareOptions { pub durable_queues: bool, } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct AMQPNotifier { exchange_name: String, channel_pool: Pool, diff --git a/src/notifiers/impls/dir_notifier.rs b/src/notifiers/impls/dir_notifier.rs index 363d914..33bb94f 100644 --- a/src/notifiers/impls/dir_notifier.rs +++ b/src/notifiers/impls/dir_notifier.rs @@ -8,7 +8,7 @@ use log::debug; use std::path::PathBuf; use tokio::process::Command; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct DirNotifier { pub dir: PathBuf, } diff --git a/src/notifiers/impls/file_notifier.rs b/src/notifiers/impls/file_notifier.rs index d01a497..e77dd6e 100644 --- a/src/notifiers/impls/file_notifier.rs +++ b/src/notifiers/impls/file_notifier.rs @@ -7,7 +7,7 @@ use axum::http::HeaderMap; use log::debug; use tokio::process::Command; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct FileNotifier { pub command: String, } diff --git a/src/notifiers/impls/http_notifier.rs b/src/notifiers/impls/http_notifier.rs index f1fd158..3254a8d 100644 --- a/src/notifiers/impls/http_notifier.rs +++ b/src/notifiers/impls/http_notifier.rs @@ -7,7 +7,7 @@ use axum::http::HeaderMap; use reqwest::Client; use std::time::Duration; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct HttpNotifier { urls: Vec, client: Client, diff --git a/src/notifiers/manager.rs b/src/notifiers/manager.rs index c77cfb7..65ed81f 100644 --- a/src/notifiers/manager.rs +++ b/src/notifiers/manager.rs @@ -9,7 +9,7 @@ use crate::{ use super::{base::Notifier, NotifierImpl}; use axum::http::HeaderMap; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct NotificationManager { notifiers: Vec, } diff --git a/src/notifiers/mod.rs b/src/notifiers/mod.rs index 5fee8dd..349c2ef 100644 --- a/src/notifiers/mod.rs +++ b/src/notifiers/mod.rs @@ -7,7 +7,7 @@ pub mod serializer; pub use manager::NotificationManager; pub use serializer::Format; -#[derive(Clone)] +#[derive(Clone, Debug)] pub enum NotifierImpl { Http(impls::http_notifier::HttpNotifier), File(impls::file_notifier::FileNotifier), diff --git a/src/server/mod.rs b/src/server/mod.rs index 95eb6e0..ce5abcc 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -11,6 +11,7 @@ use axum::{ http::HeaderValue, Router, ServiceExt, }; +use sentry_tower::{NewSentryLayer, SentryHttpLayer}; use tower::Layer; mod cors; @@ -44,16 +45,8 @@ async fn logger( let elapsed = (time.elapsed().as_micros() as f64) / 1000.0; let status = response.status().as_u16(); - // log::log!(log::Level::Info, "ememe"); if uri != "/health" { - let mut level = log::Level::Info; - if !response.status().is_success() { - level = log::Level::Error; - } - log::log!( - level, - "\"{method} {uri} {version:?}\" \"-\" \"{status}\" \"{remote}\" \"{elapsed}\"" - ); + log::info!("\"{method} {uri} {version:?}\" \"-\" \"{status}\" \"{remote}\" \"{elapsed}\""); } response @@ -142,10 +135,13 @@ pub async fn start(config: Config) -> RustusResult<()> { let state = Arc::new(RustusState::from_config(&config).await?); let tus_app = get_router(state); + let main_router = axum::Router::new() .route("/health", axum::routing::get(healthcheck)) .nest(&config.url, tus_app) - .fallback(fallback); + .fallback(fallback) + .layer(NewSentryLayer::new_from_top()) + .layer(SentryHttpLayer::with_transaction()); let service = axum::middleware::from_fn(method_replacer).layer( axum::middleware::from_fn_with_state(Arc::new(config.clone()), logger).layer(main_router), diff --git a/src/state.rs b/src/state.rs index dcc3d16..353d7aa 100644 --- a/src/state.rs +++ b/src/state.rs @@ -6,7 +6,7 @@ use crate::{ notifiers::NotificationManager, }; -#[derive(Clone)] +#[derive(Clone, Debug)] #[allow(clippy::module_name_repetitions)] pub struct RustusState { pub config: Config, diff --git a/src/utils/hashes.rs b/src/utils/hashes.rs index 826ea18..bd87a37 100644 --- a/src/utils/hashes.rs +++ b/src/utils/hashes.rs @@ -47,16 +47,12 @@ pub fn verify_chunk_checksum(header: &HeaderValue, data: &[u8]) -> RustusResult< if let Some(checksum_base) = split.next() { let checksum = base64::engine::general_purpose::STANDARD .decode(checksum_base) - .map_err(|_| { - log::error!("Can't decode checksum value"); - RustusError::WrongHeaderValue - })?; + .map_err(|_| RustusError::WrongHeaderValue)?; return checksum_verify(algo, data, checksum.as_slice()); } } Err(RustusError::WrongHeaderValue) } else { - log::error!("Can't decode checksum header."); Err(RustusError::WrongHeaderValue) } } diff --git a/src/utils/lapin_pool.rs b/src/utils/lapin_pool.rs index 4a03c2e..97a8d10 100644 --- a/src/utils/lapin_pool.rs +++ b/src/utils/lapin_pool.rs @@ -1,10 +1,12 @@ use lapin::{ChannelState, ConnectionProperties, ConnectionState}; +#[derive(Clone)] pub struct ConnnectionPool { url: String, properties: ConnectionProperties, } +#[derive(Clone, Debug)] pub struct ChannelPool { pool: mobc::Pool, } From 0b4fa1626c61ef9d0ae366504c6cfe37c4b9a948 Mon Sep 17 00:00:00 2001 From: Pavel Kirilin Date: Fri, 8 Dec 2023 00:55:58 +0100 Subject: [PATCH 2/6] Added sentry integration. Signed-off-by: Pavel Kirilin --- Cargo.lock | 876 ++++++++++--------- Cargo.toml | 24 +- deploy/Dockerfile | 7 +- src/config.rs | 38 +- src/data_storage/impls/file_storage.rs | 137 ++- src/data_storage/impls/s3_hybrid.rs | 8 +- src/errors.rs | 7 +- src/info_storages/impls/file_info_storage.rs | 5 +- src/main.rs | 48 +- src/notifiers/impls/amqp_notifier.rs | 1 + src/notifiers/impls/dir_notifier.rs | 6 +- src/notifiers/impls/file_notifier.rs | 5 +- src/notifiers/impls/http_notifier.rs | 12 +- src/notifiers/manager.rs | 17 +- src/notifiers/mod.rs | 3 +- src/notifiers/serializer.rs | 4 +- src/server/cors.rs | 2 +- src/server/mod.rs | 112 ++- src/server/routes/create.rs | 42 +- src/server/routes/delete.rs | 23 +- src/server/routes/file_info.rs | 2 +- src/server/routes/get_file.rs | 2 +- src/server/routes/upload.rs | 32 +- src/utils/result.rs | 54 +- 24 files changed, 790 insertions(+), 677 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2afb6c4..081cbbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] @@ -102,51 +102,50 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.1" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "a3a318f1f38d2418400f8209655bfd825785afd25aa30bb7ba6cc792e4596748" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "1.0.2" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -157,23 +156,12 @@ checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" [[package]] name = "async-channel" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" -dependencies = [ - "concurrent-queue", - "event-listener 2.5.3", - "futures-core", -] - -[[package]] -name = "async-channel" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d37875bd9915b7d67c2f117ea2c30a0989874d0b2cb694fe25403c85763c0c9e" +checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" dependencies = [ "concurrent-queue", - "event-listener 3.1.0", + "event-listener 4.0.0", "event-listener-strategy", "futures-core", "pin-project-lite", @@ -181,30 +169,30 @@ dependencies = [ [[package]] name = "async-executor" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0c4a4f319e45986f347ee47fef8bf5e81c9abc3f6f58dc2391439f30df65f0" +checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" dependencies = [ - "async-lock 2.8.0", + "async-lock 3.2.0", "async-task", "concurrent-queue", "fastrand 2.0.1", - "futures-lite 1.13.0", + "futures-lite 2.1.0", "slab", ] [[package]] name = "async-global-executor" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776" +checksum = "9b4353121d5644cdf2beb5726ab752e79a8db1ebb52031770ec47db31d245526" dependencies = [ - "async-channel 1.9.0", + "async-channel", "async-executor", - "async-io", - "async-lock 2.8.0", + "async-io 2.2.1", + "async-lock 3.2.0", "blocking", - "futures-lite 1.13.0", + "futures-lite 2.1.0", "once_cell", ] @@ -232,13 +220,32 @@ dependencies = [ "futures-lite 1.13.0", "log", "parking", - "polling", + "polling 2.8.0", "rustix 0.37.27", "slab", - "socket2 0.4.9", + "socket2 0.4.10", "waker-fn", ] +[[package]] +name = "async-io" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6d3b15875ba253d1110c740755e246537483f152fa334f91abd7fe84c88b3ff" +dependencies = [ + "async-lock 3.2.0", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite 2.1.0", + "parking", + "polling 3.3.1", + "rustix 0.38.26", + "slab", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "async-lock" version = "2.8.0" @@ -250,11 +257,11 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb2ab2aa8a746e221ab826c73f48bc6ba41be6763f0855cb249eb6d154cf1d7" +checksum = "7125e42787d53db9dd54261812ef17e937c95a51e4d291373b670342fa44310c" dependencies = [ - "event-listener 3.1.0", + "event-listener 4.0.0", "event-listener-strategy", "pin-project-lite", ] @@ -265,7 +272,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a6012d170ad00de56c9ee354aef2e358359deb1ec504254e0e5a3774771de0e" dependencies = [ - "async-io", + "async-io 1.13.0", "async-trait", "futures-core", "reactor-trait", @@ -285,7 +292,7 @@ checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.39", ] [[package]] @@ -300,7 +307,7 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fcf00bc6d5abb29b5f97e3c61a90b6d3caa12f3faf897d4a3e3607c050a35a7" dependencies = [ - "http", + "http 0.2.11", "log", "native-tls", "serde", @@ -327,7 +334,7 @@ dependencies = [ "rust-ini", "serde", "thiserror", - "time 0.3.30", + "time", "url", ] @@ -342,17 +349,18 @@ dependencies = [ [[package]] name = "axum" -version = "0.6.16" -source = "git+https://github.com/tokio-rs/axum.git?rev=3ff45d9#3ff45d9c96b5192af6b6ec26eb2a2bfcddd00d7d" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "202651474fe73c62d9e0a56c6133f7a0ff1dc1c8cf7a5b03381af2a26553ac9d" dependencies = [ "async-trait", "axum-core", "bytes", "futures-util", - "http", - "http-body 0.4.5", - "hyper 0.14.27", - "hyper 1.0.0-rc.4", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.0.1", "hyper-util", "itoa", "matchit", @@ -368,21 +376,22 @@ dependencies = [ "sync_wrapper", "tokio", "tower", - "tower-hyper-http-body-compat", "tower-layer", "tower-service", ] [[package]] name = "axum-core" -version = "0.3.4" -source = "git+https://github.com/tokio-rs/axum.git?rev=3ff45d9#3ff45d9c96b5192af6b6ec26eb2a2bfcddd00d7d" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77cb22c689c44d4c07b0ab44ebc25d69d8ae601a2f28fb8d672d344178fa17aa" dependencies = [ "async-trait", "bytes", "futures-util", - "http", - "http-body 0.4.5", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", "mime", "pin-project-lite", "rustversion", @@ -393,9 +402,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ "addr2line", "cc", @@ -426,9 +435,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] name = "block-buffer" @@ -454,21 +463,21 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ - "async-channel 2.1.0", - "async-lock 3.1.0", + "async-channel", + "async-lock 3.2.0", "async-task", "fastrand 2.0.1", "futures-io", - "futures-lite 2.0.1", + "futures-lite 2.1.0", "piper", "tracing", ] [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "bytes" @@ -487,9 +496,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "libc", ] @@ -502,18 +511,17 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "serde", - "time 0.1.45", "wasm-bindgen", - "winapi", + "windows-targets 0.48.5", ] [[package]] @@ -528,20 +536,19 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.21" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c27cdf28c0f604ba3f512b0c9a409f8de8513e4816705deb0498b627e7c3a3fd" +checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" dependencies = [ "clap_builder", "clap_derive", - "once_cell", ] [[package]] name = "clap_builder" -version = "4.3.21" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a9f1ab5e9f01a9b81f202e8562eb9a10de70abf9eaeac1be465c28b75aa4aa" +checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" dependencies = [ "anstream", "anstyle", @@ -551,21 +558,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.3.12" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.39", ] [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "colorchoice" @@ -600,9 +607,9 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" +checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" dependencies = [ "crossbeam-utils", ] @@ -615,9 +622,9 @@ checksum = "396de984970346b0d9e93d1415082923c679e5ae5c3ee3dcbd104f5610af126b" [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -625,15 +632,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -669,9 +676,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +checksum = "8eb30d70a07a3b04884d2677f06bec33509dc67ca60d92949e5535352d3191dc" dependencies = [ "powerfmt", "serde", @@ -747,28 +754,23 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.39", ] [[package]] -name = "errno" -version = "0.3.2" +name = "equivalent" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys", -] +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] -name = "errno-dragonfly" -version = "0.1.2" +name = "errno" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "cc", "libc", + "windows-sys 0.52.0", ] [[package]] @@ -779,9 +781,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" -version = "3.1.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2" +checksum = "770d968249b5d99410d61f5bf89057f3199a077a04d087092f58e7d10692baae" dependencies = [ "concurrent-queue", "parking", @@ -790,11 +792,11 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96b852f1345da36d551b9473fa1e2b1eb5c5195585c6c018118bc92a8d91160" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" dependencies = [ - "event-listener 3.1.0", + "event-listener 4.0.0", "pin-project-lite", ] @@ -889,9 +891,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -961,11 +963,14 @@ dependencies = [ [[package]] name = "futures-lite" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3831c2651acb5177cbd83943f3d9c8912c5ad03c76afcc0e9511ba568ec5ebb" +checksum = "aeee267a1883f7ebef3700f262d2d54de95dfaf38189015a74fdc4e0c7ad8143" dependencies = [ + "fastrand 2.0.1", "futures-core", + "futures-io", + "parking", "pin-project-lite", ] @@ -977,7 +982,7 @@ checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.39", ] [[package]] @@ -1028,33 +1033,52 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] name = "gimli" -version = "0.27.3" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "h2" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.11", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] [[package]] name = "h2" -version = "0.3.21" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +checksum = "e1d308f63daf4181410c242d34c11f928dcb3aa105852019e043c9d1f4e4368a" dependencies = [ "bytes", "fnv", "futures-core", "futures-sink", "futures-util", - "http", + "http 1.0.0", "indexmap", "slab", "tokio", @@ -1071,6 +1095,12 @@ dependencies = [ "ahash", ] +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + [[package]] name = "heck" version = "0.4.1" @@ -1079,9 +1109,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "hex" @@ -1120,6 +1150,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.5" @@ -1127,25 +1168,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", - "http", + "http 0.2.11", "pin-project-lite", ] [[package]] name = "http-body" -version = "1.0.0-rc.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "951dfc2e32ac02d67c90c0d65bd27009a635dc9b381a2cc7d284ab01e3a0150d" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" dependencies = [ "bytes", - "http", + "http 1.0.0", ] [[package]] -name = "http-range-header" -version = "0.3.1" +name = "http-body-util" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" +checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840" +dependencies = [ + "bytes", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", + "pin-project-lite", +] [[package]] name = "httparse" @@ -1169,14 +1217,14 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", - "http", + "h2 0.3.22", + "http 0.2.11", "http-body 0.4.5", "httparse", "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.9", + "socket2 0.4.10", "tokio", "tower-service", "tracing", @@ -1185,23 +1233,21 @@ dependencies = [ [[package]] name = "hyper" -version = "1.0.0-rc.4" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d280a71f348bcc670fc55b02b63c53a04ac0bf2daff2980795aeaf53edae10e6" +checksum = "403f9214f3e703236b221f1a9cd88ec8b4adfa5296de01ab96216361f4692f56" dependencies = [ "bytes", "futures-channel", "futures-util", - "h2", - "http", - "http-body 1.0.0-rc.2", + "h2 0.4.0", + "http 1.0.0", + "http-body 1.0.0", "httparse", "httpdate", "itoa", "pin-project-lite", "tokio", - "tracing", - "want", ] [[package]] @@ -1219,18 +1265,18 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.0.0" -source = "git+https://github.com/hyperium/hyper-util?rev=d97181a#d97181a278d9c59f1d7f2713732e400440861216" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca339002caeb0d159cc6e023dff48e199f081e42fa039895c7c6f38b37f2e9d" dependencies = [ "bytes", "futures-channel", "futures-util", - "http", - "http-body 1.0.0-rc.2", - "hyper 1.0.0-rc.4", - "once_cell", + "http 1.0.0", + "http-body 1.0.0", + "hyper 1.0.1", "pin-project-lite", - "socket2 0.5.3", + "socket2 0.5.5", "tokio", "tower", "tower-service", @@ -1239,16 +1285,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -1262,9 +1308,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1272,12 +1318,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.3" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ - "autocfg", - "hashbrown", + "equivalent", + "hashbrown 0.14.3", ] [[package]] @@ -1307,7 +1353,7 @@ checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ "hermit-abi", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1323,8 +1369,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "rustix 0.38.8", - "windows-sys", + "rustix 0.38.26", + "windows-sys 0.48.0", ] [[package]] @@ -1335,9 +1381,9 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" dependencies = [ "wasm-bindgen", ] @@ -1372,19 +1418,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.147" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" - -[[package]] -name = "libmimalloc-sys" -version = "0.1.35" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3979b5c37ece694f1f5e51e7ecc871fdb0f517ed04ee45f88d15d6d553cb9664" -dependencies = [ - "cc", - "libc", -] +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libredox" @@ -1392,9 +1428,9 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "libc", - "redox_syscall 0.4.1", + "redox_syscall", ] [[package]] @@ -1405,9 +1441,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.4.5" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "lock_api" @@ -1433,9 +1469,9 @@ checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" [[package]] name = "matchit" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed1202b2a6f884ae56f04cff409ab315c5ce26b5e58d7412e484f01fd52f52ef" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" [[package]] name = "maybe-async" @@ -1466,9 +1502,9 @@ checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771" [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "metrics" @@ -1491,15 +1527,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "mimalloc" -version = "0.1.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa01922b5ea280a911e323e4d2fd24b7fe5cc4042e0d2cda3c40775cdc4bdc9c" -dependencies = [ - "libmimalloc-sys", -] - [[package]] name = "mime" version = "0.3.17" @@ -1542,13 +1569,13 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys", + "wasi", + "windows-sys 0.48.0", ] [[package]] @@ -1610,9 +1637,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -1629,26 +1656,26 @@ dependencies = [ [[package]] name = "object" -version = "0.31.1" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "openssl" -version = "0.10.59" +version = "0.10.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a257ad03cd8fb16ad4172fedf8094451e1af1c4b70097636ef2eac9a5f0cc33" +checksum = "6b8419dc8cc6d866deb801274bba2e6f8f6108c1bb7fcc10ee5ab864931dbb45" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "cfg-if", "foreign-types", "libc", @@ -1665,7 +1692,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.39", ] [[package]] @@ -1676,9 +1703,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.95" +version = "0.9.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40a4130519a360279579c2053038317e40eff64d13fd3f004f9e1b72b8a6aaf9" +checksum = "c3eaad34cdd97d81de97964fc7f29e2d104f483840d906ef56daa1912338460b" dependencies = [ "cc", "libc", @@ -1693,7 +1720,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a" dependencies = [ "dlv-list", - "hashbrown", + "hashbrown 0.12.3", ] [[package]] @@ -1754,16 +1781,16 @@ checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.4.1", + "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" @@ -1782,14 +1809,14 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.39", ] [[package]] name = "pin-project-lite" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -1839,7 +1866,21 @@ dependencies = [ "libc", "log", "pin-project-lite", - "windows-sys", + "windows-sys 0.48.0", +] + +[[package]] +name = "polling" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf63fa624ab313c11656b4cda960bfc46c410187ad493c41f6ba2d8c1e991c9e" +dependencies = [ + "cfg-if", + "concurrent-queue", + "pin-project-lite", + "rustix 0.38.26", + "tracing", + "windows-sys 0.52.0", ] [[package]] @@ -1856,9 +1897,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] @@ -1875,9 +1916,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -1934,9 +1975,9 @@ dependencies = [ [[package]] name = "redis" -version = "0.23.3" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f49cdc0bb3f412bf8e7d1bd90fe1d9eb10bc5c399ba90973c14662a27b3f8ba" +checksum = "c580d9cbbe1d1b479e8d67cf9daf6a62c957e6846048408b80b43ac3f6af84cd" dependencies = [ "arc-swap", "async-trait", @@ -1949,22 +1990,13 @@ dependencies = [ "pin-project-lite", "ryu", "sha1_smol", - "socket2 0.4.9", + "socket2 0.4.10", "tokio", "tokio-retry", "tokio-util", "url", ] -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_syscall" version = "0.4.1" @@ -1987,9 +2019,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.4" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", @@ -1999,9 +2031,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.7" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", @@ -2010,9 +2042,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" @@ -2025,8 +2057,8 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2", - "http", + "h2 0.3.22", + "http 0.2.11", "http-body 0.4.5", "hyper 0.14.27", "hyper-tls", @@ -2056,16 +2088,16 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.3" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babe80d5c16becf6594aa32ad2be8fe08498e7ae60b77de8df700e67f191d7e" +checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" dependencies = [ "cc", "getrandom", "libc", "spin", "untrusted", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2093,7 +2125,7 @@ dependencies = [ "futures", "hex", "hmac", - "http", + "http 0.2.11", "log", "maybe-async", "md5", @@ -2105,7 +2137,7 @@ dependencies = [ "serde_derive", "sha2", "thiserror", - "time 0.3.30", + "time", "tokio", "tokio-stream", "url", @@ -2143,20 +2175,20 @@ dependencies = [ "io-lifetimes", "libc", "linux-raw-sys 0.3.8", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "rustix" -version = "0.38.8" +version = "0.38.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f" +checksum = "9470c4bf8246c8daf25f9598dca807fb6510347b1e1cfa55749113850c79d88a" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "errno", "libc", - "linux-raw-sys 0.4.5", - "windows-sys", + "linux-raw-sys 0.4.12", + "windows-sys 0.52.0", ] [[package]] @@ -2228,11 +2260,9 @@ dependencies = [ "enum_dispatch", "fern", "futures", - "http", "lapin", "log", "md-5", - "mimalloc", "mime", "mime_guess", "mobc", @@ -2249,6 +2279,7 @@ dependencies = [ "sha2", "strum", "thiserror", + "tikv-jemallocator", "tokio", "tokio-util", "tower", @@ -2294,7 +2325,7 @@ version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" dependencies = [ - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2344,9 +2375,9 @@ checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "sentry" -version = "0.31.8" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce4b57f1b521f674df7a1d200be8ff5d74e3712020ee25b553146657b5377d5" +checksum = "9b596ee5f4e76638de6063ca96fd3d923675416461fc7f1b77406dc2f32d1979" dependencies = [ "httpdate", "native-tls", @@ -2363,9 +2394,9 @@ dependencies = [ [[package]] name = "sentry-backtrace" -version = "0.31.8" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cc8d4e04a73de8f718dc703943666d03f25d3e9e4d0fb271ca0b8c76dfa00e" +checksum = "e6510a97162c288989a6310766bcadfc83ec98ad73121674463b055c42189e85" dependencies = [ "backtrace", "once_cell", @@ -2375,9 +2406,9 @@ dependencies = [ [[package]] name = "sentry-contexts" -version = "0.31.8" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6436c1bad22cdeb02179ea8ef116ffc217797c028927def303bc593d9320c0d1" +checksum = "64e2552a4a578aade01bd44691e6805c32bac34fc918f1675739fbbf2add8460" dependencies = [ "hostname", "libc", @@ -2389,9 +2420,9 @@ dependencies = [ [[package]] name = "sentry-core" -version = "0.31.8" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901f761681f97db3db836ef9e094acdd8756c40215326c194201941947164ef1" +checksum = "ebb7a6ad833035f6b36db3e61e450643eec8a3c5f2839b8e41c74a73e57c6bae" dependencies = [ "once_cell", "rand", @@ -2402,9 +2433,9 @@ dependencies = [ [[package]] name = "sentry-debug-images" -version = "0.31.8" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afdb263e73d22f39946f6022ed455b7561b22ff5553aca9be3c6a047fa39c328" +checksum = "0bcd02214397892a3ec25372cc68c210d858f39314535f5d640bdf41294fd441" dependencies = [ "findshlibs", "once_cell", @@ -2413,9 +2444,9 @@ dependencies = [ [[package]] name = "sentry-panic" -version = "0.31.8" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74fbf1c163f8b6a9d05912e1b272afa27c652e8b47ea60cb9a57ad5e481eea99" +checksum = "0866e2ba7615fe37e0e485f2373bf9dabbb255f82637b5fe47902095790bbbc9" dependencies = [ "sentry-backtrace", "sentry-core", @@ -2423,11 +2454,12 @@ dependencies = [ [[package]] name = "sentry-tower" -version = "0.31.8" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88e782e369edac4adfc5bf528b27577270bc3e7023c388ebad9db08e1d56b30b" +checksum = "e275f07e9e7d9cf3b85130ab6893a9790c3ab2d8fedca29215aeafad0539c4f4" dependencies = [ - "http", + "axum", + "http 1.0.0", "pin-project", "sentry-core", "tower-layer", @@ -2437,9 +2469,9 @@ dependencies = [ [[package]] name = "sentry-tracing" -version = "0.31.8" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82eabcab0a047040befd44599a1da73d3adb228ff53b5ed9795ae04535577704" +checksum = "53ef38653386354058f30b3c6d0bf764c59ee6270cd769ac4620a2d2fd60c8fe" dependencies = [ "sentry-backtrace", "sentry-core", @@ -2449,9 +2481,9 @@ dependencies = [ [[package]] name = "sentry-types" -version = "0.31.8" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da956cca56e0101998c8688bc65ce1a96f00673a0e58e663664023d4c7911e82" +checksum = "26342e85c6b3332273b820d5be6b93027fe991ded23a2aa6fb88a5a28c845c40" dependencies = [ "debugid", "hex", @@ -2459,29 +2491,29 @@ dependencies = [ "serde", "serde_json", "thiserror", - "time 0.3.30", + "time", "url", "uuid", ] [[package]] name = "serde" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.39", ] [[package]] @@ -2591,9 +2623,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" dependencies = [ "libc", "winapi", @@ -2601,12 +2633,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.3" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2649,7 +2681,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.28", + "syn 2.0.39", ] [[package]] @@ -2671,9 +2703,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.28" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -2721,15 +2753,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", "fastrand 2.0.1", - "redox_syscall 0.3.5", - "rustix 0.38.8", - "windows-sys", + "redox_syscall", + "rustix 0.38.26", + "windows-sys 0.48.0", ] [[package]] @@ -2749,7 +2781,7 @@ checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.39", ] [[package]] @@ -2763,14 +2795,23 @@ dependencies = [ ] [[package]] -name = "time" -version = "0.1.45" +name = "tikv-jemalloc-sys" +version = "0.5.4+5.3.0-patched" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" dependencies = [ + "cc", "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", +] + +[[package]] +name = "tikv-jemallocator" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "965fe0c26be5c56c94e38ba547249074803efd52adfb66de62107d95aab3eaca" +dependencies = [ + "libc", + "tikv-jemalloc-sys", ] [[package]] @@ -2819,9 +2860,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.31.0" +version = "1.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40de3a2ba249dcb097e01be5e67a5ff53cf250397715a071a81543e8a832a920" +checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" dependencies = [ "backtrace", "bytes", @@ -2831,20 +2872,20 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.3", + "socket2 0.5.5", "tokio-macros", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.39", ] [[package]] @@ -2911,35 +2952,20 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.4" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" +checksum = "09e12e6351354851911bdf8c2b8f2ab15050c567d70a8b9a37ae7b8301a4080d" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "bytes", - "futures-core", "futures-util", - "http", - "http-body 0.4.5", - "http-range-header", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", "pin-project-lite", "tower-layer", "tower-service", -] - -[[package]] -name = "tower-hyper-http-body-compat" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7ea3e622710ee44a8255baa6fcb2a34d67450e2ffb48e5e58d5a7bd6ff55a21" -dependencies = [ - "http", - "http-body 0.4.5", - "http-body 1.0.0-rc.2", - "hyper 1.0.0-rc.4", - "pin-project-lite", - "tower", - "tower-service", + "tracing", ] [[package]] @@ -2974,7 +3000,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.39", ] [[package]] @@ -3009,16 +3035,16 @@ dependencies = [ "sharded-slab", "smallvec", "thread_local", - "time 0.3.30", + "time", "tracing-core", "tracing-log", ] [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "typenum" @@ -3046,15 +3072,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -3073,9 +3099,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "ureq" -version = "2.9.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7830e33f6e25723d41a63f77e434159dad02919f18f55a512b5f16f3b1d77138" +checksum = "f8cdd25c339e200129fe4de81451814e5228c9b771d57378817d6117cc2b3f97" dependencies = [ "base64 0.21.5", "log", @@ -3086,9 +3112,9 @@ dependencies = [ [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -3104,9 +3130,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.5.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" dependencies = [ "getrandom", "serde", @@ -3145,12 +3171,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -3159,9 +3179,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3169,24 +3189,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.39", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" dependencies = [ "cfg-if", "js-sys", @@ -3196,9 +3216,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3206,22 +3226,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.39", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" [[package]] name = "wasm-streams" @@ -3238,9 +3258,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" dependencies = [ "js-sys", "wasm-bindgen", @@ -3275,12 +3295,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -3289,65 +3309,131 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] name = "windows-targets" -version = "0.48.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winreg" @@ -3356,7 +3442,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ "cfg-if", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index effc833..639fc25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ path = "src/main.rs" [dependencies] async-trait = "0.1.74" -axum = { git = "https://github.com/tokio-rs/axum.git", rev = "3ff45d9" } +axum = { version = "0.7.1" } base64 = "0.21.5" bytes = "1.5.0" chrono = { version = "0.4.26", features = ["serde"] } @@ -25,17 +25,16 @@ enum_dispatch = "0.3.12" fern = { version = "0.6.2", features = ["colored", "chrono"] } futures = "0.3.29" log = "0.4.20" -mimalloc = "0.1.39" mime = "0.3.17" mime_guess = "2.0.4" mobc = "0.8.3" -redis = { version = "0.23.3", features = ["tokio-comp", "connection-manager"] } +redis = { version = "0.24.0", features = ["tokio-comp", "connection-manager"] } rustc-hash = "1.1.0" serde = { version = "1.0.192", features = ["derive"] } serde_json = "1.0.108" strum = { version = "0.25.0", features = ["derive"] } thiserror = "1.0.50" -tokio = { version = "1.31.0", features = ["full"] } +tokio = { version = "1.31.0", features = ["full", "bytes"] } tokio-util = { version = "0.7.10", features = ["io"] } uuid = { version = "1.5.0", features = ["v4"] } rust-s3 = "^0.33" @@ -47,19 +46,26 @@ md-5 = "^0.10.1" digest = "^0.10.1" reqwest = "0.11.22" lapin = "2.3.1" -tower-http = { version = "0.4.4", features = ["cors"] } -http = "^0.2" +tower-http = { version = "0.5.0", features = ["cors", "trace"] } wildmatch = "2.1.1" tracing = "0.1.40" -sentry = { version = "0.31.8" } -sentry-tracing = "0.31.8" +sentry = "0.32.0" +sentry-tracing = "0.32.0" +sentry-tower = { version = "0.32.0", features = [ + "http", + "axum", + "axum-matched-path", +] } tracing-subscriber = { version = "0.3.18", features = [ "smallvec", "parking_lot", "time", ] } -sentry-tower = { version = "0.31.8", features = ["http"] } +[target.'cfg(not(target_env = "msvc"))'.dependencies] +tikv-jemallocator = { version = "0.5.4", features = [ + "background_threads_runtime_support", +] } [profile.release] opt-level = 3 diff --git a/deploy/Dockerfile b/deploy/Dockerfile index ceaf08b..c765847 100644 --- a/deploy/Dockerfile +++ b/deploy/Dockerfile @@ -4,11 +4,16 @@ WORKDIR /app COPY Cargo.toml Cargo.lock ./ COPY src ./src COPY imgs ./imgs + +ENV JEMALLOC_SYS_WITH_MALLOC_CONF="background_thread:true,metadata_thp:always,tcache:false,dirty_decay_ms:0,muzzy_decay_ms:0,abort_conf:true" RUN cargo build --release --bin rustus -FROM debian:bullseye-20211201-slim AS base +FROM debian:bullseye-20231120-slim AS base COPY --from=builder /app/target/release/rustus /usr/local/bin/ +RUN apt update && apt install -y libssl-dev ca-certificates libjemalloc-dev && apt clean + +VOLUME [ "/data" ] ENTRYPOINT ["/usr/local/bin/rustus"] diff --git a/src/config.rs b/src/config.rs index 143d79a..08cf677 100644 --- a/src/config.rs +++ b/src/config.rs @@ -279,12 +279,31 @@ pub struct NotificationConfig { #[derive(Parser, Clone, Debug)] pub struct SentryConfig { /// Sentry DSN. - #[arg(long, env = "RUSTUS_SENTRY_DSN")] - pub sentry_dsn: Option, + #[arg(name = "sentry-dsn", long, env = "RUSTUS_SENTRY_DSN")] + pub dsn: Option, /// Sentry sample rate. - #[arg(long, env = "RUSTUS_SENTRY_SAMPLE_RATE")] - pub sentry_sample_rate: Option, + #[arg(name = "sentry-sample-rate", long, env = "RUSTUS_SENTRY_SAMPLE_RATE")] + pub sample_rate: Option, + + /// Sentry traces sample rate. + #[arg( + name = "sentry-traces-sample-rate", + long, + env = "RUSTUS_SENTRY_TRACES_SAMPLE_RATE" + )] + pub traces_sample_rate: Option, + + #[arg(name = "sentry-environment", long, env = "RUSTUS_SENTRY_ENVIRONMENT")] + pub environment: Option, + + #[arg( + name = "sentry-debug", + long, + default_value = "false", + env = "RUSTUS_SENTRY_DEBUG" + )] + pub debug: bool, } #[derive(Parser, Clone, Debug)] @@ -301,7 +320,7 @@ pub struct Config { /// Log level for the server. #[arg(long, default_value = "INFO", env = "RUSTUS_LOG_LEVEL")] - pub log_level: tracing::level_filters::LevelFilter, + pub log_level: tracing::Level, /// Number of worker threads for the server. /// @@ -313,6 +332,15 @@ pub struct Config { #[arg(long, default_value = "/files", env = "RUSTUS_PREFIX")] pub url: String, + /// Option to disable access logging completely. + /// Useful when using sentry, to not spam with logs, + /// because sentry might incorrectly capture some access logs, + /// which is annoying. + /// + /// By default it is disabled. + #[arg(long, default_value = "false", env = "RUSTUS_NO_ACCESS")] + pub no_access: bool, + /// Disable access log for health endpoint. /// By default it is enabled. #[arg(long, env = "RUSTUS_DISABLE_HEALTH_ACCESS_LOG")] diff --git a/src/data_storage/impls/file_storage.rs b/src/data_storage/impls/file_storage.rs index 52667c5..709e4c7 100644 --- a/src/data_storage/impls/file_storage.rs +++ b/src/data_storage/impls/file_storage.rs @@ -1,12 +1,10 @@ -use std::{io::Write, path::PathBuf}; +use std::path::PathBuf; + +use tokio::io::AsyncWriteExt; use axum::response::{IntoResponse, Response}; use bytes::Bytes; -use log::error; -use std::{ - fs::{remove_file, DirBuilder, OpenOptions}, - io::{copy, BufReader, BufWriter}, -}; +use std::fs::DirBuilder; use crate::{ data_storage::base::Storage, @@ -82,45 +80,42 @@ impl Storage for FileStorage { Ok(resp) } - async fn add_bytes(&self, file_info: &FileInfo, bytes: Bytes) -> RustusResult<()> { + async fn add_bytes(&self, file_info: &FileInfo, mut bytes: Bytes) -> RustusResult<()> { // In normal situation this `if` statement is not // gonna be called, but what if it is ... - if file_info.path.is_none() { + let Some(path) = &file_info.path else { return Err(RustusError::FileNotFound); + }; + let file = tokio::fs::OpenOptions::new() + .write(true) + .append(true) + .create(false) + .read(false) + .truncate(false) + .open(path.as_str()) + .await?; + let mut writer = tokio::io::BufWriter::new(file); + writer.write_all(&mut bytes).await?; + writer.flush().await?; + if self.force_fsync { + writer.get_ref().sync_data().await?; } - let path = file_info.path.as_ref().unwrap().clone(); - let force_sync = self.force_fsync; - tokio::task::spawn_blocking(move || { - // Opening file in w+a mode. - // It means that we're going to append some - // bytes to the end of a file. - let file = OpenOptions::new() - .write(true) - .append(true) - .create(false) - .read(false) - .truncate(false) - .open(path.as_str())?; - let mut writer = BufWriter::new(file); - writer.write_all(bytes.as_ref())?; - writer.flush()?; - if force_sync { - writer.get_ref().sync_data()?; - } - Ok(()) - }) - .await? + writer.into_inner().shutdown().await?; + bytes.clear(); + Ok(()) } async fn create_file(&self, file_info: &FileInfo) -> RustusResult { // New path to file. let file_path = self.data_file_path(file_info.id.as_str())?; - OpenOptions::new() + let mut opened = tokio::fs::OpenOptions::new() .create(true) .write(true) .truncate(true) .create_new(true) - .open(file_path.as_path())?; + .open(file_path.as_path()) + .await?; + opened.shutdown().await?; Ok(file_path.display().to_string()) } @@ -129,54 +124,48 @@ impl Storage for FileStorage { file_info: &FileInfo, parts_info: Vec, ) -> RustusResult<()> { - let force_fsync = self.force_fsync; - if file_info.path.is_none() { + let Some(path) = &file_info.path else { return Err(RustusError::FileNotFound); - } - let path = file_info.path.as_ref().unwrap().clone(); - tokio::task::spawn_blocking(move || { - let file = OpenOptions::new() - .write(true) - .append(true) - .create(true) - .open(path)?; - let mut writer = BufWriter::new(file); - for part in parts_info { - if part.path.is_none() { - return Err(RustusError::FileNotFound); - } - let part_file = OpenOptions::new() - .read(true) - .open(part.path.as_ref().unwrap())?; - let mut reader = BufReader::new(part_file); - copy(&mut reader, &mut writer)?; - } - writer.flush()?; - if force_fsync { - writer.get_ref().sync_data()?; + }; + let file = tokio::fs::OpenOptions::new() + .write(true) + .append(true) + .create(true) + .open(path) + .await?; + let mut writer = tokio::io::BufWriter::new(file); + for part in parts_info { + if part.path.is_none() { + return Err(RustusError::FileNotFound); } - Ok(()) - }) - .await? + let part_file = tokio::fs::OpenOptions::new() + .read(true) + .open(part.path.as_ref().unwrap()) + .await?; + let mut reader = tokio::io::BufReader::new(part_file); + tokio::io::copy_buf(&mut reader, &mut writer).await?; + reader.shutdown().await? + } + writer.flush().await?; + if self.force_fsync { + writer.get_ref().sync_data().await?; + } + writer.into_inner().shutdown().await?; + Ok(()) } async fn remove_file(&self, file_info: &FileInfo) -> RustusResult<()> { - let info = file_info.clone(); - if info.path.is_none() { + let Some(path) = &file_info.path else { + return Err(RustusError::FileNotFound); + }; + let data_path = PathBuf::from(path); + if !data_path.exists() { return Err(RustusError::FileNotFound); } - tokio::task::spawn_blocking(move || { - // Let's remove the file itself. - let data_path = PathBuf::from(info.path.as_ref().unwrap().clone()); - if !data_path.exists() { - return Err(RustusError::FileNotFound); - } - remove_file(data_path).map_err(|err| { - error!("{:?}", err); - RustusError::UnableToRemove(info.id.clone()) - })?; - Ok(()) - }) - .await? + tokio::fs::remove_file(data_path).await.map_err(|err| { + tracing::error!("{:?}", err); + RustusError::UnableToRemove(String::from(path.as_str())) + })?; + Ok(()) } } diff --git a/src/data_storage/impls/s3_hybrid.rs b/src/data_storage/impls/s3_hybrid.rs index 6b5ef1e..fed2673 100644 --- a/src/data_storage/impls/s3_hybrid.rs +++ b/src/data_storage/impls/s3_hybrid.rs @@ -76,9 +76,9 @@ impl S3HybridStorage { let headers_map = serde_json::from_str::>(raw_s3_headers) .mlog_err("Cannot parse s3 headers. Please provide valid JSON object.") .unwrap(); - log::debug!("Found extra s3 headers."); + tracing::debug!("Found extra s3 headers."); for (key, value) in &headers_map { - log::debug!("Adding header `{key}` with value `{value}`."); + tracing::debug!("Adding header `{key}` with value `{value}`."); bucket.add_header(key, value); } } @@ -103,7 +103,7 @@ impl S3HybridStorage { return Err(RustusError::UnableToWrite("Cannot get upload path.".into())); } let s3_path = self.get_s3_key(file_info); - log::debug!( + tracing::debug!( "Starting uploading {} to S3 with key `{}`", file_info.id, s3_path, @@ -133,7 +133,7 @@ impl Storage for S3HybridStorage { async fn get_contents(&self, file_info: &FileInfo) -> RustusResult { if file_info.length != Some(file_info.offset) { - log::debug!("File isn't uploaded. Returning from local storage."); + tracing::debug!("File isn't uploaded. Returning from local storage."); return self.local_storage.get_contents(file_info).await; } let key = self.get_s3_key(file_info); diff --git a/src/errors.rs b/src/errors.rs index b75e93b..8b2c2e8 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,7 +1,6 @@ use std::io::{Error, ErrorKind}; use axum::response::IntoResponse; -use log::error; use axum::http::StatusCode; @@ -45,8 +44,6 @@ pub enum RustusError { HttpRequestError(#[from] reqwest::Error), #[error("Hook invocation failed. Reason: {0}")] HookError(String), - #[error("Unable to configure logging: {0}")] - LogConfigError(#[from] log::SetLoggerError), #[error("AMQP error: {0}")] AMQPError(#[from] lapin::Error), #[error("AMQP pooling error error: {0}")] @@ -61,7 +58,7 @@ pub enum RustusError { WrongChecksum, #[error("The header value is incorrect")] WrongHeaderValue, - #[error("HTTP hook error. Returned status: {0}, Response text: {1}")] + #[error("HTTP hook error. Returned status: {0}.")] HTTPHookError(u16, String, Option), #[error("Found S3 error: {0}")] S3Error(#[from] s3::error::S3Error), @@ -102,7 +99,7 @@ impl IntoResponse for RustusError { fn into_response(self) -> axum::response::Response { let status_code = self.get_status_code(); if status_code != StatusCode::NOT_FOUND { - log::error!("{self}"); + tracing::error!(err=?self, "{self}"); } match self { RustusError::HTTPHookError(_, proxy_response, content_type) => { diff --git a/src/info_storages/impls/file_info_storage.rs b/src/info_storages/impls/file_info_storage.rs index fb19085..d7fb55a 100644 --- a/src/info_storages/impls/file_info_storage.rs +++ b/src/info_storages/impls/file_info_storage.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; -use tokio::fs::DirBuilder; +use tokio::{fs::DirBuilder, io::AsyncWriteExt}; use crate::{ errors::{RustusError, RustusResult}, @@ -46,6 +46,8 @@ impl InfoStorage for FileInfoStorage { let str_data = serde_json::to_string(file_info)?; let mut writer = tokio::io::BufWriter::new(file); tokio::io::copy_buf(&mut str_data.as_bytes(), &mut writer).await?; + writer.flush().await?; + writer.shutdown().await?; Ok(()) } @@ -60,6 +62,7 @@ impl InfoStorage for FileInfoStorage { tokio::io::copy_buf(&mut reader, &mut contents) .await .mlog_dbg("Cannot write bytes")?; + reader.shutdown().await?; Ok(serde_json::from_slice::(contents.as_slice())?) } diff --git a/src/main.rs b/src/main.rs index fe63454..753e05b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,8 @@ #![allow(async_fn_in_trait)] -use std::str::FromStr; +use std::{borrow::Cow, str::FromStr}; use errors::RustusResult; -use sentry::types::Dsn; -use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; pub mod config; pub mod data_storage; @@ -17,8 +15,9 @@ pub mod server; pub mod state; pub mod utils; +#[cfg(not(target_env = "msvc"))] #[global_allocator] -static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; +static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; #[cfg_attr(coverage, no_coverage)] fn greeting(app_conf: &config::Config) { @@ -48,32 +47,33 @@ fn greeting(app_conf: &config::Config) { fn main() -> RustusResult<()> { let args = config::Config::parse(); + greeting(&args); let mut _guard = None; - if let Some(sentry_dsn) = &args.sentry_config.sentry_dsn { + if let Some(sentry_dsn) = &args.sentry_config.dsn { + let default_options = sentry::ClientOptions::default(); _guard = Some(sentry::init(sentry::ClientOptions { - dsn: Dsn::from_str(sentry_dsn.as_str()).ok(), + dsn: sentry::types::Dsn::from_str(sentry_dsn.as_str()).ok(), // Enable capturing of traces; set this a to lower value in production: - traces_sample_rate: 1.0, - ..sentry::ClientOptions::default() + sample_rate: args + .sentry_config + .sample_rate + .unwrap_or(default_options.sample_rate), + traces_sample_rate: args + .sentry_config + .traces_sample_rate + .unwrap_or(default_options.traces_sample_rate), + environment: args + .sentry_config + .environment + .clone() + .map(|val| Cow::from(val)) + .clone(), + release: sentry::release_name!(), + debug: args.sentry_config.debug, + ..default_options })); } - tracing_subscriber::registry() - .with(tracing_subscriber::filter::filter_fn(move |a| { - a.level() <= &args.log_level - })) - .with( - tracing_subscriber::fmt::layer() - .with_level(true) - .with_file(false) - .with_line_number(false) - .with_target(false) - .compact(), - ) - .with(sentry_tracing::layer()) - .init(); - - greeting(&args); let mut builder = if Some(1) == args.workers { tokio::runtime::Builder::new_current_thread() } else { diff --git a/src/notifiers/impls/amqp_notifier.rs b/src/notifiers/impls/amqp_notifier.rs index 6add534..3156ac3 100644 --- a/src/notifiers/impls/amqp_notifier.rs +++ b/src/notifiers/impls/amqp_notifier.rs @@ -150,6 +150,7 @@ impl Notifier for AMQPNotifier { Ok(()) } + #[tracing::instrument(skip(self, message, _header_map))] async fn send_message( &self, message: String, diff --git a/src/notifiers/impls/dir_notifier.rs b/src/notifiers/impls/dir_notifier.rs index 33bb94f..28cf908 100644 --- a/src/notifiers/impls/dir_notifier.rs +++ b/src/notifiers/impls/dir_notifier.rs @@ -4,7 +4,6 @@ use crate::{ RustusResult, }; use axum::http::HeaderMap; -use log::debug; use std::path::PathBuf; use tokio::process::Command; @@ -26,6 +25,7 @@ impl Notifier for DirNotifier { Ok(()) } + #[tracing::instrument(skip(self, message, _headers_map))] async fn send_message( &self, message: String, @@ -34,12 +34,12 @@ impl Notifier for DirNotifier { ) -> RustusResult<()> { let hook_path = self.dir.join(hook.to_string()); if !hook_path.exists() { - debug!("Hook {} not found.", hook.to_string()); + tracing::debug!("Hook {} not found.", hook.to_string()); return Err(RustusError::HookError(format!( "Hook file {hook} not found." ))); } - debug!("Running hook: {}", hook_path.as_path().display()); + tracing::debug!("Running hook: {}", hook_path.as_path().display()); let mut command = Command::new(hook_path).arg(message).spawn()?; let stat = command.wait().await?; if !stat.success() { diff --git a/src/notifiers/impls/file_notifier.rs b/src/notifiers/impls/file_notifier.rs index e77dd6e..647e255 100644 --- a/src/notifiers/impls/file_notifier.rs +++ b/src/notifiers/impls/file_notifier.rs @@ -4,7 +4,6 @@ use crate::{ RustusResult, }; use axum::http::HeaderMap; -use log::debug; use tokio::process::Command; #[derive(Clone, Debug)] @@ -25,19 +24,21 @@ impl Notifier for FileNotifier { Ok(()) } + #[tracing::instrument(err, skip(self, message, _headers_map), fields(exit_status = tracing::field::Empty))] async fn send_message( &self, message: String, hook: Hook, _headers_map: &HeaderMap, ) -> RustusResult<()> { - debug!("Running command: {}", self.command.as_str()); + tracing::debug!("Running command: {}", self.command.as_str()); let mut command = Command::new(self.command.as_str()) .arg(hook.to_string()) .arg(message) .spawn()?; let stat = command.wait().await?; if !stat.success() { + tracing::Span::current().record("exit_status", &stat.code().unwrap_or(0)); return Err(RustusError::HookError("Returned wrong status code".into())); } Ok(()) diff --git a/src/notifiers/impls/http_notifier.rs b/src/notifiers/impls/http_notifier.rs index 3254a8d..52fe18b 100644 --- a/src/notifiers/impls/http_notifier.rs +++ b/src/notifiers/impls/http_notifier.rs @@ -34,16 +34,17 @@ impl Notifier for HttpNotifier { Ok(()) } + #[tracing::instrument(err, skip(self, message, header_map), fields(response_body = tracing::field::Empty))] async fn send_message( &self, message: String, hook: Hook, header_map: &HeaderMap, ) -> RustusResult<()> { - log::debug!("Starting HTTP Hook."); + tracing::debug!("Starting HTTP Hook."); let idempotency_key = uuid::Uuid::new_v4().to_string(); let requests_vec = self.urls.iter().map(|url| { - log::debug!("Preparing request for {}", url); + tracing::debug!("Preparing request for {}", url); let mut request = self .client .post(url.as_str()) @@ -67,12 +68,7 @@ impl Notifier for HttpNotifier { .and_then(|hval| hval.to_str().ok().map(String::from)); let status = real_resp.status().as_u16(); let text = real_resp.text().await.unwrap_or_default(); - log::warn!( - "Got wrong response for `{hook}`. Status code: `{status}`, body: `{body}`", - hook = hook, - status = status, - body = text, - ); + tracing::Span::current().record("response_body", &text); return Err(RustusError::HTTPHookError(status, text, content_type)); } } diff --git a/src/notifiers/manager.rs b/src/notifiers/manager.rs index 65ed81f..96ddadf 100644 --- a/src/notifiers/manager.rs +++ b/src/notifiers/manager.rs @@ -8,6 +8,7 @@ use crate::{ use super::{base::Notifier, NotifierImpl}; use axum::http::HeaderMap; +use tracing::Instrument; #[derive(Clone, Debug)] pub struct NotificationManager { @@ -25,21 +26,21 @@ impl NotificationManager { let mut manager = Self { notifiers: Vec::new(), }; - log::debug!("Initializing notification manager."); + tracing::debug!("Initializing notification manager."); if let Some(hooks_file) = &rustus_config.notification_config.hooks_file { - log::debug!("Found hooks file"); + tracing::debug!("Found hooks file"); manager .notifiers .push(NotifierImpl::File(FileNotifier::new(hooks_file.clone()))); } if let Some(hooks_dir) = &rustus_config.notification_config.hooks_dir { - log::debug!("Found hooks directory"); + tracing::debug!("Found hooks directory"); manager .notifiers .push(NotifierImpl::Dir(DirNotifier::new(hooks_dir.clone()))); } if !rustus_config.notification_config.hooks_http_urls.is_empty() { - log::debug!("Found http hook urls."); + tracing::debug!("Found http hook urls."); manager.notifiers.push(NotifierImpl::Http(HttpNotifier::new( rustus_config.notification_config.hooks_http_urls.clone(), rustus_config @@ -55,12 +56,12 @@ impl NotificationManager { .hooks_amqp_url .is_some() { - log::debug!("Found AMQP notifier."); + tracing::debug!("Found AMQP notifier."); manager.notifiers.push(NotifierImpl::Amqp(AMQPNotifier::new( rustus_config.notification_config.amqp_hook_opts.clone(), ))); } - log::debug!("Notification manager initialized."); + tracing::debug!("Notification manager initialized."); manager } @@ -83,7 +84,8 @@ impl NotificationManager { /// # Errors /// /// This method might fail in case if any of the notifiers fails. - pub async fn send_message( + #[tracing::instrument(skip(self, hook, headers_map))] + pub async fn notify_all( &self, message: String, hook: super::hooks::Hook, @@ -92,6 +94,7 @@ impl NotificationManager { for notifier in &self.notifiers { notifier .send_message(message.clone(), hook, headers_map) + .in_current_span() .await?; } Ok(()) diff --git a/src/notifiers/mod.rs b/src/notifiers/mod.rs index 349c2ef..af7b6c2 100644 --- a/src/notifiers/mod.rs +++ b/src/notifiers/mod.rs @@ -4,6 +4,7 @@ pub mod impls; pub mod manager; pub mod serializer; +use axum::http::HeaderMap; pub use manager::NotificationManager; pub use serializer::Format; @@ -28,7 +29,7 @@ impl base::Notifier for NotifierImpl { &self, message: String, hook: hooks::Hook, - headers_map: &http::HeaderMap, + headers_map: &HeaderMap, ) -> crate::errors::RustusResult<()> { match self { Self::Http(http) => http.send_message(message, hook, headers_map).await, diff --git a/src/notifiers/serializer.rs b/src/notifiers/serializer.rs index c449a9e..3529cbf 100644 --- a/src/notifiers/serializer.rs +++ b/src/notifiers/serializer.rs @@ -1,6 +1,6 @@ use std::{collections::HashMap, hash::BuildHasherDefault, net::SocketAddr}; -use http::{HeaderMap, Uri}; +use axum::http::{HeaderMap, Method, Uri}; use rustc_hash::FxHasher; use serde_json::{json, Value}; @@ -29,7 +29,7 @@ impl Format { pub fn format( &self, uri: &Uri, - method: &http::Method, + method: &Method, addr: &SocketAddr, headers: &HeaderMap, proxy_enabled: bool, diff --git a/src/server/cors.rs b/src/server/cors.rs index 4d6b0bc..8a3d04e 100644 --- a/src/server/cors.rs +++ b/src/server/cors.rs @@ -1,6 +1,6 @@ use std::{str::FromStr, time::Duration}; -use http::{HeaderName, HeaderValue, Method}; +use axum::http::{HeaderName, HeaderValue, Method}; use tower_http::cors::{AllowOrigin, CorsLayer, MaxAge}; use wildmatch::WildMatch; diff --git a/src/server/mod.rs b/src/server/mod.rs index ce5abcc..e60b409 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -1,57 +1,24 @@ use std::{ net::{Ipv4Addr, SocketAddr, SocketAddrV4}, sync::Arc, + time::Duration, }; use crate::{ config::Config, errors::RustusResult, state::RustusState, utils::headers::HeaderMapExt, }; use axum::{ - extract::{ConnectInfo, DefaultBodyLimit, State}, + extract::{ConnectInfo, DefaultBodyLimit, MatchedPath, Request, State}, http::HeaderValue, + response::Response, Router, ServiceExt, }; -use sentry_tower::{NewSentryLayer, SentryHttpLayer}; use tower::Layer; +use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; mod cors; mod routes; -async fn logger( - State(config): State>, - req: axum::extract::Request, - next: axum::middleware::Next, -) -> impl axum::response::IntoResponse { - let default_addr = ConnectInfo(SocketAddr::V4(SocketAddrV4::new( - Ipv4Addr::new(0, 0, 0, 0), - 8000, - ))); - let socket = req - .extensions() - .get::>() - .unwrap_or(&default_addr); - let remote = req.headers().get_remote_ip(socket, config.behind_proxy); - let method = req.method().to_string(); - let uri = req - .uri() - .path_and_query() - .map(ToString::to_string) - .unwrap_or_default(); - - let time = std::time::Instant::now(); - let version = req.version(); - let response = next.run(req).await; - #[allow(clippy::cast_precision_loss)] - let elapsed = (time.elapsed().as_micros() as f64) / 1000.0; - let status = response.status().as_u16(); - - if uri != "/health" { - log::info!("\"{method} {uri} {version:?}\" \"-\" \"{status}\" \"{remote}\" \"{elapsed}\""); - } - - response -} - async fn method_replacer( mut req: axum::extract::Request, next: axum::middleware::Next, @@ -130,26 +97,75 @@ pub fn get_router(state: Arc) -> Router { /// /// This function returns an error if the server fails to start. pub async fn start(config: Config) -> RustusResult<()> { - let listener = tokio::net::TcpListener::bind((config.host.clone(), config.port)).await?; - log::info!("Starting server at http://{}:{}", config.host, config.port); - let state = Arc::new(RustusState::from_config(&config).await?); + let behind_proxy = config.behind_proxy; + let default_addr = ConnectInfo(SocketAddr::V4(SocketAddrV4::new( + Ipv4Addr::new(0, 0, 0, 0), + 0, + ))); - let tus_app = get_router(state); + tracing_subscriber::registry() + .with(tracing_subscriber::filter::LevelFilter::from_level( + config.log_level, + )) + .with( + tracing_subscriber::fmt::layer() + .with_level(true) + .with_file(false) + .with_line_number(false) + .with_target(false), + ) + .with(sentry_tracing::layer()) + .init(); + + let tracer = tower_http::trace::TraceLayer::new_for_http() + .make_span_with(move |request: &Request| { + let matched_path = request + .extensions() + .get::() + .map(MatchedPath::as_str); + let socket_addr = request + .extensions() + .get::>() + .unwrap_or(&default_addr); + let ip = request.headers().get_remote_ip(socket_addr, behind_proxy); + tracing::info_span!( + "request", + method = ?request.method(), + matched_path, + version = ?request.version(), + ip = ip, + status = tracing::field::Empty, + ) + }) + .on_response( + |response: &Response, latency: Duration, span: &tracing::Span| { + span.record("status", &response.status().as_u16()); + span.record("duration", latency.as_millis()); + tracing::info!("response"); + }, + ); - let main_router = axum::Router::new() + let state = Arc::new(RustusState::from_config(&config).await?); + let tus_app = get_router(state); + let mut main_router = axum::Router::new() .route("/health", axum::routing::get(healthcheck)) .nest(&config.url, tus_app) .fallback(fallback) - .layer(NewSentryLayer::new_from_top()) - .layer(SentryHttpLayer::with_transaction()); + .layer(tracer); - let service = axum::middleware::from_fn(method_replacer).layer( - axum::middleware::from_fn_with_state(Arc::new(config.clone()), logger).layer(main_router), - ); + if config.sentry_config.dsn.is_some() { + main_router = main_router + .layer(sentry_tower::NewSentryLayer::new_from_top()) + .layer(sentry_tower::SentryHttpLayer::new()); + } + let listener = tokio::net::TcpListener::bind((config.host.clone(), config.port)).await?; + tracing::info!("Starting server at http://{}:{}", config.host, config.port); axum::serve( listener, - service.into_make_service_with_connect_info::(), + axum::middleware::from_fn(method_replacer) + .layer(main_router) + .into_make_service_with_connect_info::(), ) .await?; Ok(()) diff --git a/src/server/routes/create.rs b/src/server/routes/create.rs index 5d9381b..e4800db 100644 --- a/src/server/routes/create.rs +++ b/src/server/routes/create.rs @@ -2,24 +2,20 @@ use std::{net::SocketAddr, sync::Arc}; use axum::{ extract::{ConnectInfo, State}, - http::{HeaderMap, StatusCode}, + http::{HeaderMap, Method, StatusCode, Uri}, response::{IntoResponse, Response}, }; use bytes::Bytes; -use http::{Method, Uri}; +use tracing::Instrument; use crate::{ - data_storage::base::Storage, - errors::RustusResult, - extensions::TusExtensions, - info_storages::base::InfoStorage, - models::file_info::FileInfo, - notifiers::hooks::Hook, - state::RustusState, - utils::{headers::HeaderMapExt, result::MonadLogger}, + data_storage::base::Storage, errors::RustusResult, extensions::TusExtensions, + info_storages::base::InfoStorage, models::file_info::FileInfo, notifiers::hooks::Hook, + state::RustusState, utils::headers::HeaderMapExt, }; #[allow(clippy::too_many_lines)] +#[tracing::instrument(level = "info", skip_all, fields(upload_id = tracing::field::Empty))] pub async fn handler( uri: Uri, method: Method, @@ -68,6 +64,8 @@ pub async fn handler( let meta = headers.get_metadata(); let file_id = uuid::Uuid::new_v4().to_string(); + tracing::Span::current().record("upload_id", &file_id); + let mut file_info = FileInfo::new( file_id.as_str(), upload_len, @@ -142,7 +140,7 @@ pub async fn handler( { state .notificator - .send_message( + .notify_all( state.config.notification_config.hooks_format.format( &uri, &method, @@ -198,19 +196,15 @@ pub async fn handler( let moved_state = state.clone(); // Adding send_message task to tokio reactor. // Thin function would be executed in background. - tokio::task::spawn(async move { - moved_state - .notificator - .send_message(message, post_hook, &headers) - .await - .mlog_warn( - format!( - "Failed to send PostReceive hook for upload {}", - file_info.id - ) - .as_str(), - ) - }); + tokio::task::spawn( + async move { + moved_state + .notificator + .notify_all(message, post_hook, &headers) + .await + } + .in_current_span(), + ); } Ok(( diff --git a/src/server/routes/delete.rs b/src/server/routes/delete.rs index 8a2d8ba..e43598d 100644 --- a/src/server/routes/delete.rs +++ b/src/server/routes/delete.rs @@ -2,10 +2,10 @@ use std::{net::SocketAddr, sync::Arc}; use axum::{ extract::{ConnectInfo, Path, State}, - http::StatusCode, + http::{HeaderMap, Method, StatusCode, Uri}, response::{IntoResponse, Response}, }; -use http::{HeaderMap, Method, Uri}; +use tracing::Instrument; use crate::{ data_storage::base::Storage, @@ -14,7 +14,6 @@ use crate::{ info_storages::base::InfoStorage, notifiers::hooks::Hook, state::RustusState, - utils::result::MonadLogger, }; pub async fn handler( @@ -45,7 +44,7 @@ pub async fn handler( { state .notificator - .send_message( + .notify_all( state.config.notification_config.hooks_format.format( &uri, &method, @@ -77,13 +76,15 @@ pub async fn handler( &file_info, ); let state_cln = state.clone(); - tokio::spawn(async move { - state_cln - .notificator - .send_message(msg, Hook::PostTerminate, &headers) - .await - .mlog_warn("Cannot send PostTerminate hook") - }); + tokio::spawn( + async move { + state_cln + .notificator + .notify_all(msg, Hook::PostTerminate, &headers) + .await + } + .in_current_span(), + ); } Ok(StatusCode::NO_CONTENT.into_response()) diff --git a/src/server/routes/file_info.rs b/src/server/routes/file_info.rs index 747a795..37b732f 100644 --- a/src/server/routes/file_info.rs +++ b/src/server/routes/file_info.rs @@ -2,9 +2,9 @@ use std::sync::Arc; use axum::{ extract::{Path, State}, + http::StatusCode, response::Response, }; -use reqwest::StatusCode; use crate::{ data_storage::base::Storage, errors::RustusResult, info_storages::base::InfoStorage, diff --git a/src/server/routes/get_file.rs b/src/server/routes/get_file.rs index 668b94e..24226c5 100644 --- a/src/server/routes/get_file.rs +++ b/src/server/routes/get_file.rs @@ -2,9 +2,9 @@ use std::sync::Arc; use axum::{ extract::{Path, State}, + http::StatusCode, response::{IntoResponse, Response}, }; -use reqwest::StatusCode; use crate::{ data_storage::base::Storage, diff --git a/src/server/routes/upload.rs b/src/server/routes/upload.rs index 83c81dd..2e2f6b0 100644 --- a/src/server/routes/upload.rs +++ b/src/server/routes/upload.rs @@ -2,11 +2,11 @@ use std::{net::SocketAddr, sync::Arc}; use axum::{ extract::{ConnectInfo, Path, State}, - http::{HeaderMap, StatusCode}, + http::{HeaderMap, Method, StatusCode, Uri}, response::IntoResponse, }; use bytes::Bytes; -use http::{Method, Uri}; +use tracing::Instrument; use crate::{ data_storage::base::Storage, @@ -15,9 +15,10 @@ use crate::{ info_storages::base::InfoStorage, notifiers::hooks::Hook, state::RustusState, - utils::{hashes::verify_chunk_checksum, headers::HeaderMapExt, result::MonadLogger}, + utils::{hashes::verify_chunk_checksum, headers::HeaderMapExt}, }; +#[tracing::instrument(level = "info", skip_all, fields(upload_id = tracing::field::Empty))] pub async fn handler( uri: Uri, method: Method, @@ -27,6 +28,7 @@ pub async fn handler( Path(upload_id): Path, body: Bytes, ) -> RustusResult { + tracing::Span::current().record("upload_id", &upload_id.as_str()); if !headers.check("Content-Type", |val| { val == "application/offset+octet-stream" }) { @@ -134,20 +136,16 @@ pub async fn handler( ); let headers_clone = headers.clone(); - tokio::spawn(async move { - state_clone - .notificator - .send_message(msg, hook, &headers_clone) - .await - .mlog_warn( - format!( - "Failed to send PostReceive hook for upload {}", - file_info.id - ) - .as_str(), - ) - .ok(); - }); + tokio::spawn( + async move { + state_clone + .notificator + .notify_all(msg, hook, &headers_clone) + .await + .ok(); + } + .in_current_span(), + ); } Ok(( diff --git a/src/utils/result.rs b/src/utils/result.rs index 09a60e8..399bf3b 100644 --- a/src/utils/result.rs +++ b/src/utils/result.rs @@ -1,53 +1,41 @@ use std::fmt::Display; -pub trait MonadLogger { +pub trait MonadLogger: Sized { #[must_use] - fn mlog(self, level: log::Level, msg: &str) -> Self; - #[must_use] - fn mlog_err(self, msg: &str) -> Self; - #[must_use] - fn mlog_warn(self, msg: &str) -> Self; - #[must_use] - fn mlog_dbg(self, msg: &str) -> Self; -} + fn _should_log(&self) -> bool; -impl MonadLogger for Result { - fn mlog(self, level: log::Level, msg: &str) -> Self { - if let Err(err) = &self { - log::log!(level, "{msg}: {err}"); + fn mlog_err(self, msg: &str) -> Self { + if self._should_log() { + tracing::error!(msg) } self } - fn mlog_err(self, msg: &str) -> Self { - self.mlog(log::Level::Error, msg) - } - fn mlog_warn(self, msg: &str) -> Self { - self.mlog(log::Level::Warn, msg) + if self._should_log() { + tracing::warn!(msg) + } + self } + #[allow(unused_variables)] fn mlog_dbg(self, msg: &str) -> Self { - self.mlog(log::Level::Debug, msg) - } -} - -impl MonadLogger for Option { - fn mlog(self, level: log::Level, msg: &str) -> Self { - if self.is_none() { - log::log!(level, "{msg}: The value is None"); + #[cfg(debug_assertions)] + if self._should_log() { + tracing::debug!(msg) } self } - fn mlog_err(self, msg: &str) -> Self { - self.mlog(log::Level::Error, msg) - } +} - fn mlog_warn(self, msg: &str) -> Self { - self.mlog(log::Level::Warn, msg) +impl MonadLogger for Result { + fn _should_log(&self) -> bool { + self.is_err() } +} - fn mlog_dbg(self, msg: &str) -> Self { - self.mlog(log::Level::Debug, msg) +impl MonadLogger for Option { + fn _should_log(&self) -> bool { + self.is_none() } } From ef77ad2cd4673c76825f42921f3fe671e959add8 Mon Sep 17 00:00:00 2001 From: Pavel Kirilin Date: Mon, 11 Dec 2023 00:49:38 +0100 Subject: [PATCH 3/6] Changed subscriber to be optional. Signed-off-by: Pavel Kirilin --- src/server/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index e60b409..24b6be1 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -103,6 +103,11 @@ pub async fn start(config: Config) -> RustusResult<()> { 0, ))); + let mut sentry_layer = None; + if config.sentry_config.dsn.is_some() { + sentry_layer = Some(sentry_tracing::layer()); + } + tracing_subscriber::registry() .with(tracing_subscriber::filter::LevelFilter::from_level( config.log_level, @@ -114,7 +119,7 @@ pub async fn start(config: Config) -> RustusResult<()> { .with_line_number(false) .with_target(false), ) - .with(sentry_tracing::layer()) + .with(sentry_layer) .init(); let tracer = tower_http::trace::TraceLayer::new_for_http() From 8b9571ff90bc0c9a574f7e11edd789bb71597dad Mon Sep 17 00:00:00 2001 From: Pavel Kirilin Date: Mon, 11 Dec 2023 01:17:34 +0100 Subject: [PATCH 4/6] Added CLI docs for sentry. Signed-off-by: Pavel Kirilin --- docs/configuration.md | 4 +++- src/config.rs | 24 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 7254b3c..4079a27 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -74,7 +74,8 @@ please provide sentry-dsn to rustus. ``` bash rustus --sentry-dsn "https://user@sentry-instance.com/11" \ - --sentry-sample-rate 1.0 + --sentry-sample-rate 1.0 \ + --sentry-environment "dev" ``` === "ENV" @@ -82,6 +83,7 @@ please provide sentry-dsn to rustus. ``` bash export RUSTUS_SENTRY_DSN="https://user@sentry-instance.com/11" export RUSTUS_SENTRY_SAMPLE_RATE="1.0" + export RUSTUS_SENTRY_ENVIRONMENT="dev" rustus ``` diff --git a/src/config.rs b/src/config.rs index 08cf677..52ad974 100644 --- a/src/config.rs +++ b/src/config.rs @@ -279,14 +279,28 @@ pub struct NotificationConfig { #[derive(Parser, Clone, Debug)] pub struct SentryConfig { /// Sentry DSN. + /// + /// Link to sentry project, which is used to send events to. #[arg(name = "sentry-dsn", long, env = "RUSTUS_SENTRY_DSN")] pub dsn: Option, /// Sentry sample rate. - #[arg(name = "sentry-sample-rate", long, env = "RUSTUS_SENTRY_SAMPLE_RATE")] + /// + /// This option is used to set how often events are sent to sentry. + /// The default value is 1.0, which means that all events are sent. + #[arg( + name = "sentry-sample-rate", + long, + default_value = "1.0", + env = "RUSTUS_SENTRY_SAMPLE_RATE" + )] pub sample_rate: Option, /// Sentry traces sample rate. + /// + /// This option is used to set how often traces are sent to sentry. + /// Traces are used to track performance, so this option might not be + /// useful for regular users. #[arg( name = "sentry-traces-sample-rate", long, @@ -294,9 +308,17 @@ pub struct SentryConfig { )] pub traces_sample_rate: Option, + /// Sentry environment. + /// + /// This option is used to set environment for sentry. #[arg(name = "sentry-environment", long, env = "RUSTUS_SENTRY_ENVIRONMENT")] pub environment: Option, + /// DEvelopment option for sentry. + /// + /// This option enables logging of sentry events, + /// which is useful for debugging. But it is not recommended + /// to enable this option in production. #[arg( name = "sentry-debug", long, From 9ef4d6992c98344a3723466de6555587eeeda830 Mon Sep 17 00:00:00 2001 From: Pavel Kirilin Date: Mon, 11 Dec 2023 01:37:47 +0100 Subject: [PATCH 5/6] Fixed lints. Signed-off-by: Pavel Kirilin --- src/data_storage/impls/file_storage.rs | 4 ++-- src/main.rs | 3 ++- src/notifiers/impls/file_notifier.rs | 2 +- src/server/mod.rs | 2 +- src/server/routes/upload.rs | 2 +- src/utils/result.rs | 9 ++++++--- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/data_storage/impls/file_storage.rs b/src/data_storage/impls/file_storage.rs index 709e4c7..0515dbc 100644 --- a/src/data_storage/impls/file_storage.rs +++ b/src/data_storage/impls/file_storage.rs @@ -95,7 +95,7 @@ impl Storage for FileStorage { .open(path.as_str()) .await?; let mut writer = tokio::io::BufWriter::new(file); - writer.write_all(&mut bytes).await?; + writer.write_all(&bytes).await?; writer.flush().await?; if self.force_fsync { writer.get_ref().sync_data().await?; @@ -144,7 +144,7 @@ impl Storage for FileStorage { .await?; let mut reader = tokio::io::BufReader::new(part_file); tokio::io::copy_buf(&mut reader, &mut writer).await?; - reader.shutdown().await? + reader.shutdown().await?; } writer.flush().await?; if self.force_fsync { diff --git a/src/main.rs b/src/main.rs index 753e05b..90fee77 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,6 +48,7 @@ fn greeting(app_conf: &config::Config) { fn main() -> RustusResult<()> { let args = config::Config::parse(); greeting(&args); + #[allow(clippy::no_effect_underscore_binding)] let mut _guard = None; if let Some(sentry_dsn) = &args.sentry_config.dsn { let default_options = sentry::ClientOptions::default(); @@ -66,7 +67,7 @@ fn main() -> RustusResult<()> { .sentry_config .environment .clone() - .map(|val| Cow::from(val)) + .map(Cow::from) .clone(), release: sentry::release_name!(), debug: args.sentry_config.debug, diff --git a/src/notifiers/impls/file_notifier.rs b/src/notifiers/impls/file_notifier.rs index 647e255..6c1e258 100644 --- a/src/notifiers/impls/file_notifier.rs +++ b/src/notifiers/impls/file_notifier.rs @@ -38,7 +38,7 @@ impl Notifier for FileNotifier { .spawn()?; let stat = command.wait().await?; if !stat.success() { - tracing::Span::current().record("exit_status", &stat.code().unwrap_or(0)); + tracing::Span::current().record("exit_status", stat.code().unwrap_or(0)); return Err(RustusError::HookError("Returned wrong status code".into())); } Ok(()) diff --git a/src/server/mod.rs b/src/server/mod.rs index 24b6be1..cc80dc0 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -144,7 +144,7 @@ pub async fn start(config: Config) -> RustusResult<()> { }) .on_response( |response: &Response, latency: Duration, span: &tracing::Span| { - span.record("status", &response.status().as_u16()); + span.record("status", response.status().as_u16()); span.record("duration", latency.as_millis()); tracing::info!("response"); }, diff --git a/src/server/routes/upload.rs b/src/server/routes/upload.rs index 2e2f6b0..5a4cfff 100644 --- a/src/server/routes/upload.rs +++ b/src/server/routes/upload.rs @@ -28,7 +28,7 @@ pub async fn handler( Path(upload_id): Path, body: Bytes, ) -> RustusResult { - tracing::Span::current().record("upload_id", &upload_id.as_str()); + tracing::Span::current().record("upload_id", upload_id.as_str()); if !headers.check("Content-Type", |val| { val == "application/offset+octet-stream" }) { diff --git a/src/utils/result.rs b/src/utils/result.rs index 399bf3b..d50b044 100644 --- a/src/utils/result.rs +++ b/src/utils/result.rs @@ -4,25 +4,28 @@ pub trait MonadLogger: Sized { #[must_use] fn _should_log(&self) -> bool; + #[must_use] fn mlog_err(self, msg: &str) -> Self { if self._should_log() { - tracing::error!(msg) + tracing::error!(msg); } self } + #[must_use] fn mlog_warn(self, msg: &str) -> Self { if self._should_log() { - tracing::warn!(msg) + tracing::warn!(msg); } self } + #[must_use] #[allow(unused_variables)] fn mlog_dbg(self, msg: &str) -> Self { #[cfg(debug_assertions)] if self._should_log() { - tracing::debug!(msg) + tracing::debug!(msg); } self } From d988bd202139c4927dbb1aaf66b35f6243928ab0 Mon Sep 17 00:00:00 2001 From: Pavel Kirilin Date: Tue, 12 Dec 2023 21:45:04 +0100 Subject: [PATCH 6/6] Added log filtering. Signed-off-by: Pavel Kirilin --- src/server/mod.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index cc80dc0..73e4d3f 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -9,8 +9,8 @@ use crate::{ }; use axum::{ extract::{ConnectInfo, DefaultBodyLimit, MatchedPath, Request, State}, - http::HeaderValue, - response::Response, + http::{HeaderValue, StatusCode}, + response::{IntoResponse, Response}, Router, ServiceExt, }; use tower::Layer; @@ -54,7 +54,11 @@ async fn add_tus_header( } async fn healthcheck() -> impl axum::response::IntoResponse { - axum::http::StatusCode::OK + let mut response = StatusCode::OK.into_response(); + response + .headers_mut() + .insert("X-NO-LOG", HeaderValue::from_static("1")); + response } async fn fallback() -> impl axum::response::IntoResponse { @@ -143,10 +147,16 @@ pub async fn start(config: Config) -> RustusResult<()> { ) }) .on_response( - |response: &Response, latency: Duration, span: &tracing::Span| { + move |response: &Response, latency: Duration, span: &tracing::Span| { span.record("status", response.status().as_u16()); span.record("duration", latency.as_millis()); - tracing::info!("response"); + if config.no_access { + return; + } + if response.headers().contains_key("X-NO-LOG") { + return; + } + tracing::info!("access log"); }, );