From 81eaf22be0e5745b21e209b2d6c1aa16df64422f Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Thu, 20 Jul 2023 14:42:51 -0400 Subject: [PATCH] Experimental sentry integration --- Cargo.toml | 11 +++++++++++ src/cli/main.rs | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 98dfa8e..6c9ba54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,9 +12,19 @@ license = "GPL-3.0" keywords = [] categories = [] +[features] +default = ["sentry"] + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] protomask-tun = { path = "protomask-tun", version = "0.1.0" } +sentry = { version = "0.31.5", default-features = false, optional = true, features = [ + "reqwest", + "rustls", + "backtrace", + "contexts", + "panic" +] } tokio = { version = "1.29.1", features = [ "macros", "rt-multi-thread", @@ -38,6 +48,7 @@ rtnetlink = "0.13.0" futures = "0.3.28" prometheus = "0.13.3" lazy_static = "1.4.0" +cfg-if="1.0.0" [[bin]] name = "protomask" diff --git a/src/cli/main.rs b/src/cli/main.rs index f2f2355..13ea33c 100644 --- a/src/cli/main.rs +++ b/src/cli/main.rs @@ -1,5 +1,6 @@ //! This is the entrypoint for `protomask` from the command line. +use cfg_if::cfg_if; use clap::Parser; use config::Config; use logging::enable_logger; @@ -26,6 +27,17 @@ pub async fn main() { std::process::exit(1); } + // Enable Sentry reporting + cfg_if! { + if #[cfg(feature = "sentry")] { + log::debug!("Enabling Sentry reporting"); + let _guard = sentry::init(("https://376a29d0fd7c40d0a82f05a7e8c3600e@o4504175421947904.ingest.sentry.io/4505563054080000", sentry::ClientOptions { + release: sentry::release_name!(), + ..Default::default() + })); + } + } + // Create the NAT64 instance let mut nat64 = Nat64::new( config.nat64_prefix,