diff --git a/autoendpoint/src/extractors/notification.rs b/autoendpoint/src/extractors/notification.rs index a7b745549..c381060f9 100644 --- a/autoendpoint/src/extractors/notification.rs +++ b/autoendpoint/src/extractors/notification.rs @@ -148,6 +148,10 @@ impl Notification { message_id.encrypt(fernet) } + pub fn has_topic(&self) -> bool { + self.headers.topic.is_some() + } + /// Serialize the notification for delivery to the connection server. Some /// fields in `autopush_common`'s `Notification` are marked with /// `#[serde(skip_serializing)]` so they are not shown to the UA. These diff --git a/autoendpoint/src/routers/webpush.rs b/autoendpoint/src/routers/webpush.rs index 2ac6aae7f..ab575378b 100644 --- a/autoendpoint/src/routers/webpush.rs +++ b/autoendpoint/src/routers/webpush.rs @@ -65,6 +65,12 @@ impl Router for WebPushRouter { ); } Err(error) => { + if error.is_timeout() { + self.metrics.incr("error.node.timeout")?; + }; + if error.is_connect() { + self.metrics.incr("error.node.connect")?; + } debug!("Error while sending webpush notification: {}", error); self.remove_node_id(user, node_id).await? } diff --git a/autoendpoint/src/routes/webpush.rs b/autoendpoint/src/routes/webpush.rs index 834d2cb1b..44f0a2d8b 100644 --- a/autoendpoint/src/routes/webpush.rs +++ b/autoendpoint/src/routes/webpush.rs @@ -25,7 +25,6 @@ pub async fn webpush_route( RouterType::from_str(¬ification.subscription.user.router_type) .map_err(|_| ApiErrorKind::InvalidRouterType)?, ); - Ok(router.route_notification(¬ification).await?.into()) } diff --git a/autopush-common/src/db/dynamodb/mod.rs b/autopush-common/src/db/dynamodb/mod.rs index 060efd9a4..a2ac9d6b8 100644 --- a/autopush-common/src/db/dynamodb/mod.rs +++ b/autopush-common/src/db/dynamodb/mod.rs @@ -511,6 +511,7 @@ impl DbClient for DdbClientImpl { } async fn save_message(&self, uaid: &Uuid, message: Notification) -> DbResult<()> { + let topic = message.topic.is_some().to_string(); let input = PutItemInput { item: serde_dynamodb::to_hashmap(&NotificationRecord::from_notif(uaid, message))?, table_name: self.settings.message_table.clone(), @@ -524,6 +525,10 @@ impl DbClient for DdbClientImpl { ) .await?; + self.metrics + .incr_with_tags("notification.message.stored") + .with_tag("topic", &topic) + .send(); Ok(()) } @@ -543,6 +548,9 @@ impl DbClient for DdbClientImpl { retryable_delete_error(self.metrics.clone()), ) .await?; + self.metrics + .incr_with_tags("notification.message.deleted") + .send(); Ok(()) }