chore: don't report authentication errors to sentry (#6948)

Do we want to track 401s in sentry? If we see a lot of them, something
is likely wrong but I guess there is some level of 401s that users will
just run into.

Is there a way of marking these as "might not be a really bad error"?

---------

Co-authored-by: Not Applicable <ReactorScram@users.noreply.github.com>
This commit is contained in:
Thomas Eizinger
2024-10-08 17:26:39 +11:00
committed by GitHub
parent 027ef60ded
commit 02b0e1dc8d
4 changed files with 24 additions and 11 deletions

View File

@@ -48,3 +48,13 @@ pub enum DisconnectError {
#[error("connection to the portal failed: {0}")]
PortalConnectionFailed(#[from] phoenix_channel::Error),
}
impl DisconnectError {
pub fn is_authentication_error(&self) -> bool {
let Self::PortalConnectionFailed(e) = self else {
return false;
};
e.is_authentication_error()
}
}

View File

@@ -150,7 +150,15 @@ async fn connect_supervisor<CB>(
tracing::info!("connlib exited gracefully");
}
Ok(Err(e)) => {
telemetry::capture_error(&e);
if e.is_authentication_error() {
telemetry::capture_message(
"Portal authentication error",
telemetry::Level::Warning,
);
} else {
telemetry::capture_error(&e);
}
tracing::error!("connlib failed: {e}");
callbacks.on_disconnect(&e);
}

View File

@@ -9,7 +9,7 @@
//! Otherwise we would just make it a normal binary crate.
use anyhow::{Context as _, Result};
use connlib_client_shared::{Callbacks, DisconnectError};
use connlib_client_shared::Callbacks;
use connlib_model::ResourceView;
use firezone_bin_shared::platform::DnsControlMethod;
use std::{
@@ -97,16 +97,10 @@ pub struct CallbackHandler {
impl Callbacks for CallbackHandler {
fn on_disconnect(&self, error: &connlib_client_shared::DisconnectError) {
tracing::error!(?error, "Got `on_disconnect` from connlib");
let is_authentication_error = if let DisconnectError::PortalConnectionFailed(error) = error
{
error.is_authentication_error()
} else {
false
};
self.cb_tx
.try_send(ConnlibMsg::OnDisconnect {
error_msg: error.to_string(),
is_authentication_error,
is_authentication_error: error.is_authentication_error(),
})
.expect("should be able to send OnDisconnect");
}

View File

@@ -2,8 +2,9 @@ use arc_swap::ArcSwapOption;
use std::time::Duration;
pub use sentry::{
add_breadcrumb, capture_error, configure_scope, end_session, end_session_with_status,
start_transaction, types::protocol::v7::SessionStatus, Breadcrumb, Hub, TransactionContext,
add_breadcrumb, capture_error, capture_message, configure_scope, end_session,
end_session_with_status, start_transaction, types::protocol::v7::SessionStatus, Breadcrumb,
Hub, Level, TransactionContext,
};
pub struct Dsn(&'static str);