Skip to content

Commit

Permalink
feat: quiet more router errors from sentry (#368)
Browse files Browse the repository at this point in the history
* feat: quiet more router errors from sentry

while trying not to duplicate metrics emitted by the handle_error callbacks

(see SYNC-3695 for the eventual cleanup of this)

also update h2 per recent RUSTSEC

Issue SYNC-3635
  • Loading branch information
pjenvey committed Apr 25, 2023
1 parent 0067ae4 commit f90fc06
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
1 change: 1 addition & 0 deletions .cargo/audit.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ ignore = [
"RUSTSEC-2021-0078", # Bound by Rusoto 0.42, Reqwest 0.9 requiring Hyper 0.12
"RUSTSEC-2021-0079", # Bound by Rusoto 0.42, Reqwest 0.9, a2 0.5 requiring Hyper 0.12
"RUSTSEC-2021-0124", # Bound by tokio restrictions, rusoto, reqwest, hyper...
"RUSTSEC-2023-0034", # Bound by Rusoto 0.42, Reqwest 0.9, a2 0.5 requiring Hyper 0.12
]
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion autoendpoint/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl ApiErrorKind {
pub fn metric_label(&self) -> Option<&'static str> {
Some(match self {
ApiErrorKind::PayloadError(_) => "payload_error",
ApiErrorKind::Router(e) => e.metric_label().unwrap_or("router"),
ApiErrorKind::Router(e) => return e.metric_label(),

ApiErrorKind::Validation(_) => "validation",
ApiErrorKind::InvalidEncryption(_) => "invalid_encryption",
Expand Down
36 changes: 22 additions & 14 deletions autoendpoint/src/routers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,20 @@ impl RouterError {
}

pub fn metric_label(&self) -> Option<&'static str> {
// NOTE: Some metrics are emitted for other Errors via handle_error
// callbacks, whereas some are emitted via this method. These 2 should
// be consoliated: https://mozilla-hub.atlassian.net/browse/SYNC-3695
let err = match self {
RouterError::Fcm(e) => match e {
FcmError::InvalidAppId(_) | FcmError::NoAppId => "fcm_badappid",
_ => "",
},
RouterError::Adm(e) => match e {
AdmError::NoProfile | AdmError::InvalidProfile => "adm_profile",
_ => "",
},
RouterError::Apns(e) => match e {
ApnsError::Unregistered => "apns_unregistered",
ApnsError::SizeLimit(_) => "apns_oversized",
_ => "",
},
RouterError::Adm(e) if matches!(e, AdmError::InvalidProfile | AdmError::NoProfile) => {
"notification.bridge.error.adm.profile"
}
RouterError::Apns(ApnsError::SizeLimit(_)) => {
"notification.bridge.error.apns.oversized"
}
RouterError::Fcm(e) if matches!(e, FcmError::InvalidAppId(_) | FcmError::NoAppId) => {
"notification.bridge.error.fcm.badappid"
}
RouterError::TooMuchData(_) => "notification.bridge.error.too_much_data",
_ => "",
};
if !err.is_empty() {
Expand All @@ -188,10 +188,18 @@ impl RouterError {
pub fn is_sentry_event(&self) -> bool {
match self {
RouterError::Adm(e) => !matches!(e, AdmError::InvalidProfile | AdmError::NoProfile),
// apns handle_error emits a metric for ApnsError::Unregistered
RouterError::Apns(ApnsError::SizeLimit(_))
| RouterError::Apns(ApnsError::Unregistered) => false,
RouterError::Fcm(e) => !matches!(e, FcmError::InvalidAppId(_) | FcmError::NoAppId),
RouterError::TooMuchData(_) => false,
// common handle_error emits metrics for these
RouterError::Authentication
| RouterError::GCMAuthentication
| RouterError::Connect(_)
| RouterError::NotFound
| RouterError::RequestTimeout
| RouterError::TooMuchData(_)
| RouterError::Upstream { .. } => false,
_ => true,
}
}
Expand Down

0 comments on commit f90fc06

Please sign in to comment.