From babf29d2172743a753527ba91c0a2585db948549 Mon Sep 17 00:00:00 2001 From: strawberry Date: Fri, 29 Mar 2024 19:59:02 -0400 Subject: [PATCH] fix sentry features, add sentry_traces_sample_rate Signed-off-by: strawberry --- Cargo.lock | 233 +++++++++++++++++++++++++++++++++++++---- Cargo.toml | 2 +- conduwuit-example.toml | 8 ++ src/config/mod.rs | 7 ++ src/main.rs | 1 + 5 files changed, 230 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f3d629b6..d2112243 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -132,7 +132,7 @@ dependencies = [ "bytes", "futures-util", "headers", - "http", + "http 0.2.12", "http-body", "hyper", "itoa", @@ -161,7 +161,7 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http", + "http 0.2.12", "http-body", "mime", "rustversion", @@ -178,11 +178,11 @@ dependencies = [ "arc-swap", "bytes", "futures-util", - "http", + "http 0.2.12", "http-body", "hyper", "pin-project-lite", - "rustls", + "rustls 0.21.10", "rustls-pemfile", "tokio", "tokio-rustls", @@ -197,7 +197,7 @@ checksum = "3d1a8f5076b5dbfeb706bcce30fe73caf20971e6e5ca80b83a7f1d990e73e185" dependencies = [ "axum-server", "bytes", - "http", + "http 0.2.12", "hyper", "pin-project", "tokio", @@ -438,7 +438,7 @@ dependencies = [ "futures-util", "hickory-resolver", "hmac", - "http", + "http 0.2.12", "hyper", "hyperlocal", "image", @@ -737,6 +737,18 @@ dependencies = [ "version_check", ] +[[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 = "flate2" version = "1.0.28" @@ -834,9 +846,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", + "futures-io", "futures-macro", "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", "slab", @@ -898,7 +912,7 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.12", "indexmap", "slab", "tokio", @@ -934,7 +948,7 @@ dependencies = [ "base64 0.21.7", "bytes", "headers-core", - "http", + "http 0.2.12", "httpdate", "mime", "sha1", @@ -946,7 +960,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" dependencies = [ - "http", + "http 0.2.12", ] [[package]] @@ -1063,6 +1077,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -1070,7 +1095,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.12", "pin-project-lite", ] @@ -1103,7 +1128,7 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", + "http 0.2.12", "http-body", "httparse", "httpdate", @@ -1123,9 +1148,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", - "http", + "http 0.2.12", "hyper", - "rustls", + "rustls 0.21.10", "tokio", "tokio-rustls", ] @@ -1757,6 +1782,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "os_info" +version = "3.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae99c7fa6dd38c7cafe1ec085e804f8f555a2f8659b0dbe03f1f9963a9b51092" +dependencies = [ + "log", + "serde", + "windows-sys 0.52.0", +] + [[package]] name = "overload" version = "0.1.1" @@ -2108,7 +2144,7 @@ dependencies = [ "futures-util", "h2", "hickory-resolver", - "http", + "http 0.2.12", "http-body", "hyper", "hyper-rustls", @@ -2119,7 +2155,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls", + "rustls 0.21.10", "rustls-native-certs", "rustls-pemfile", "serde", @@ -2135,6 +2171,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "webpki-roots 0.25.4", "winreg", ] @@ -2202,7 +2239,7 @@ dependencies = [ "as_variant", "assign", "bytes", - "http", + "http 0.2.12", "js_int", "js_option", "maplit", @@ -2222,7 +2259,7 @@ dependencies = [ "base64 0.21.7", "bytes", "form_urlencoded", - "http", + "http 0.2.12", "indexmap", "js_int", "konst", @@ -2421,10 +2458,24 @@ checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", "ring", - "rustls-webpki", + "rustls-webpki 0.101.7", "sct", ] +[[package]] +name = "rustls" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" +dependencies = [ + "log", + "ring", + "rustls-pki-types", + "rustls-webpki 0.102.2", + "subtle", + "zeroize", +] + [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -2446,6 +2497,12 @@ dependencies = [ "base64 0.21.7", ] +[[package]] +name = "rustls-pki-types" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "048a63e5b3ac996d78d402940b5fa47973d2d080c6c6fffa1d0f19c4445310b7" + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -2456,6 +2513,17 @@ dependencies = [ "untrusted", ] +[[package]] +name = "rustls-webpki" +version = "0.102.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.14" @@ -2534,7 +2602,46 @@ version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "766448f12e44d68e675d5789a261515c46ac6ccd240abdd451a9c46c84a49523" dependencies = [ + "httpdate", + "reqwest", + "rustls 0.21.10", + "sentry-backtrace", + "sentry-contexts", "sentry-core", + "sentry-debug-images", + "sentry-log", + "sentry-panic", + "sentry-tower", + "sentry-tracing", + "tokio", + "ureq", + "webpki-roots 0.25.4", +] + +[[package]] +name = "sentry-backtrace" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32701cad8b3c78101e1cd33039303154791b0ff22e7802ed8cc23212ef478b45" +dependencies = [ + "backtrace", + "once_cell", + "regex", + "sentry-core", +] + +[[package]] +name = "sentry-contexts" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ddd2a91a13805bd8dab4ebf47323426f758c35f7bf24eacc1aded9668f3824" +dependencies = [ + "hostname", + "libc", + "os_info", + "rustc_version", + "sentry-core", + "uname", ] [[package]] @@ -2550,12 +2657,58 @@ dependencies = [ "serde_json", ] +[[package]] +name = "sentry-debug-images" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4d0a615e5eeca5699030620c119a094e04c14cf6b486ea1030460a544111a7" +dependencies = [ + "findshlibs", + "once_cell", + "sentry-core", +] + +[[package]] +name = "sentry-log" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2d7cd58e7b31a1a533163abf86c182824ea8f8867853a6b402cde053595a54b" +dependencies = [ + "log", + "sentry-core", +] + +[[package]] +name = "sentry-panic" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1c18d0b5fba195a4950f2f4c31023725c76f00aabb5840b7950479ece21b5ca" +dependencies = [ + "sentry-backtrace", + "sentry-core", +] + +[[package]] +name = "sentry-tower" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d87dfe009138dc515009842619b562e03b2b3f926a91318ec7ae23d09435f8b4" +dependencies = [ + "http 1.1.0", + "pin-project", + "sentry-core", + "tower-layer", + "tower-service", + "url", +] + [[package]] name = "sentry-tracing" version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3012699a9957d7f97047fd75d116e22d120668327db6e7c59824582e16e791b2" dependencies = [ + "sentry-backtrace", "sentry-core", "tracing-core", "tracing-subscriber", @@ -3072,7 +3225,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls", + "rustls 0.21.10", "tokio", ] @@ -3173,7 +3326,7 @@ dependencies = [ "bytes", "futures-core", "futures-util", - "http", + "http 0.2.12", "http-body", "http-range-header", "pin-project-lite", @@ -3315,6 +3468,15 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e36a83ea2b3c704935a01b4642946aadd445cea40b10935e3f8bd8052b8193d6" +[[package]] +name = "uname" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b72f89f0ca32e4db1c04e2a72f5345d59796d4866a1ee0609084569f73683dc8" +dependencies = [ + "libc", +] + [[package]] name = "uncased" version = "0.9.10" @@ -3357,6 +3519,22 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" +[[package]] +name = "ureq" +version = "2.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11f214ce18d8b2cbe84ed3aa6486ed3f5b285cf8d8fbdbce9f3f767a724adc35" +dependencies = [ + "base64 0.21.7", + "log", + "once_cell", + "rustls 0.22.3", + "rustls-pki-types", + "rustls-webpki 0.102.2", + "url", + "webpki-roots 0.26.1", +] + [[package]] name = "url" version = "2.5.0" @@ -3532,6 +3710,21 @@ dependencies = [ "url", ] +[[package]] +name = "webpki-roots" +version = "0.25.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" + +[[package]] +name = "webpki-roots" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "weezl" version = "0.1.8" diff --git a/Cargo.toml b/Cargo.toml index d7ac1d37..498e4a2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -174,7 +174,7 @@ features = ["rt-tokio"] version = "0.32.2" optional = true default-features = false -default = ["backtrace", "contexts", "debug-images", "panic", "transport", "rustls", "tower", "tower-http", "tracing", "reqwest", "log"] +features = ["backtrace", "contexts", "debug-images", "panic", "rustls", "tower", "tower-http", "tracing", "reqwest", "log"] [dependencies.sentry-tracing] version = "0.32.2" optional = true diff --git a/conduwuit-example.toml b/conduwuit-example.toml index 577c3353..9ad35e3f 100644 --- a/conduwuit-example.toml +++ b/conduwuit-example.toml @@ -33,6 +33,7 @@ # trusted_servers = ["matrix.org"] # Sentry.io crash/panic reporting, performance monitoring/metrics, etc. +# Conduwuit's Sentry reporting endpoint is o4506996327251968.ingest.us.sentry.io # # Defaults to false #sentry = false @@ -42,6 +43,13 @@ # Defaults to false #sentry_send_server_name = false +# Performance monitoring/tracing sample rate for Sentry.io +# +# Note that too high values may impact performance, and can be disabled by setting it to 0.0 +# +# Defaults to 0.15 +#sentry_traces_sample_rate = 0.15 + ### Database configuration diff --git a/src/config/mod.rs b/src/config/mod.rs index a07fa5da..9a516db1 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -236,6 +236,8 @@ pub struct Config { pub sentry: bool, #[serde(default)] pub sentry_send_server_name: bool, + #[serde(default = "default_sentry_traces_sample_rate")] + pub sentry_traces_sample_rate: f32, #[serde(flatten)] #[allow(clippy::zero_sized_map_values)] // this is a catchall, the map shouldn't be zero at runtime @@ -527,6 +529,9 @@ impl fmt::Display for Config { &self.allow_check_for_updates.to_string(), ), ("Enable netburst on startup", &self.startup_netburst.to_string()), + ("Sentry.io reporting and tracing", &self.sentry.to_string()), + ("Sentry.io send server_name in logs", &self.sentry_send_server_name.to_string()), + ("Sentry.io tracing sample rate", &self.sentry_traces_sample_rate.to_string()), ]; let mut msg: String = "Active config values:\n\n".to_owned(); @@ -684,3 +689,5 @@ fn default_url_preview_max_spider_size() -> usize { } fn default_new_user_displayname_suffix() -> String { "🏳️‍⚧️".to_owned() } + +fn default_sentry_traces_sample_rate() -> f32 { 0.15 } diff --git a/src/main.rs b/src/main.rs index 9748137c..6a87c0b5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -92,6 +92,7 @@ fn main() { "https://fe2eb4536aa04949e28eff3128d64757@o4506996327251968.ingest.us.sentry.io/4506996334657536", sentry::ClientOptions { release: sentry::release_name!(), + traces_sample_rate: config.sentry_traces_sample_rate, server_name: if config.sentry_send_server_name { Some(config.server_name.to_string().into()) } else {