From c12a02e3481d128bf241d5614406d42411228ef6 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 25 Oct 2024 06:59:52 +1100 Subject: [PATCH] chore(apple): start telemetry together with connlib session (#7152) This starts up telemetry together with each `connlib` session. At a later point, we can also integrate the native Swift SDK into the MacOS / iOS app to catch non-connlib specific problems. --------- Signed-off-by: Thomas Eizinger --- rust/Cargo.lock | 1 + rust/connlib/clients/apple/Cargo.toml | 1 + rust/connlib/clients/apple/src/lib.rs | 11 ++++++++++- rust/telemetry/src/lib.rs | 1 + website/src/components/Changelog/Apple.tsx | 3 +++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 3001abea8..9da020cc2 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1080,6 +1080,7 @@ dependencies = [ "connlib-client-shared", "connlib-model", "firezone-logging", + "firezone-telemetry", "ip_network", "libc", "oslog", diff --git a/rust/connlib/clients/apple/Cargo.toml b/rust/connlib/clients/apple/Cargo.toml index 3b1213d1d..4a5451143 100644 --- a/rust/connlib/clients/apple/Cargo.toml +++ b/rust/connlib/clients/apple/Cargo.toml @@ -13,6 +13,7 @@ backoff = "0.4.0" connlib-client-shared = { workspace = true } connlib-model = { workspace = true } firezone-logging = { workspace = true } +firezone-telemetry = { workspace = true } ip_network = "0.4" libc = "0.2" phoenix-channel = { workspace = true } diff --git a/rust/connlib/clients/apple/src/lib.rs b/rust/connlib/clients/apple/src/lib.rs index 074c6ab2b..27cbb449c 100644 --- a/rust/connlib/clients/apple/src/lib.rs +++ b/rust/connlib/clients/apple/src/lib.rs @@ -8,6 +8,8 @@ use anyhow::Result; use backoff::ExponentialBackoffBuilder; use connlib_client_shared::{Callbacks, DisconnectError, Session, V4RouteList, V6RouteList}; use connlib_model::ResourceView; +use firezone_telemetry::Telemetry; +use firezone_telemetry::APPLE_DSN; use ip_network::{Ipv4Network, Ipv6Network}; use phoenix_channel::get_user_agent; use phoenix_channel::LoginUrl; @@ -102,6 +104,8 @@ pub struct WrappedSession { reason = "Logger handle must be kept alive until Session is dropped" )] logger: firezone_logging::file::Handle, + + telemetry: Telemetry, } // SAFETY: `CallbackHandler.swift` promises to be thread-safe. @@ -193,6 +197,9 @@ impl WrappedSession { callback_handler: ffi::CallbackHandler, device_info: String, ) -> Result { + let telemetry = Telemetry::default(); + telemetry.start(&api_url, env!("CARGO_PKG_VERSION"), APPLE_DSN); + let logger = init_logging(log_dir.into(), log_filter)?; install_rustls_crypto_provider(); @@ -239,6 +246,7 @@ impl WrappedSession { inner: session, runtime, logger, + telemetry, }) } @@ -257,7 +265,8 @@ impl WrappedSession { } fn disconnect(self) { - self.inner.disconnect() + self.inner.disconnect(); + self.telemetry.stop(); } } diff --git a/rust/telemetry/src/lib.rs b/rust/telemetry/src/lib.rs index dd9346d3a..3621f7d2b 100644 --- a/rust/telemetry/src/lib.rs +++ b/rust/telemetry/src/lib.rs @@ -15,6 +15,7 @@ pub struct Dsn(&'static str); // > DSNs are safe to keep public because they only allow submission of new events and related event data; they do not allow read access to any information. // +pub const APPLE_DSN: Dsn = Dsn("https://66c71f83675f01abfffa8eb977bcbbf7@o4507971108339712.ingest.us.sentry.io/4508175177023488"); pub const GATEWAY_DSN: Dsn = Dsn("https://f763102cc3937199ec483fbdae63dfdc@o4507971108339712.ingest.us.sentry.io/4508162914451456"); pub const GUI_DSN: Dsn = Dsn("https://2e17bf5ed24a78c0ac9e84a5de2bd6fc@o4507971108339712.ingest.us.sentry.io/4508008945549312"); pub const HEADLESS_DSN: Dsn = Dsn("https://bc27dca8bb37be0142c48c4f89647c13@o4507971108339712.ingest.us.sentry.io/4508010028728320"); diff --git a/website/src/components/Changelog/Apple.tsx b/website/src/components/Changelog/Apple.tsx index afeb7b05e..5186fe444 100644 --- a/website/src/components/Changelog/Apple.tsx +++ b/website/src/components/Changelog/Apple.tsx @@ -13,6 +13,9 @@ export default function Apple() { {/* When you cut a release, remove any solved issues from the "known issues" lists over in `client-apps`. This must not be done when the issue's PR merges. */} Handles DNS queries over TCP correctly. + + Adds always-on error reporting using sentry.io. +