Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Add back missing metrics #372

Merged
merged 8 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions autoendpoint/src/extractors/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions autoendpoint/src/routers/webpush.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?
}
Expand Down
1 change: 0 additions & 1 deletion autoendpoint/src/routes/webpush.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pub async fn webpush_route(
RouterType::from_str(&notification.subscription.user.router_type)
.map_err(|_| ApiErrorKind::InvalidRouterType)?,
);

Ok(router.route_notification(&notification).await?.into())
}

Expand Down
8 changes: 8 additions & 0 deletions autopush-common/src/db/dynamodb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ impl DbClient for DdbClientImpl {
}

async fn save_message(&self, uaid: &Uuid, message: Notification) -> DbResult<()> {
let topic = message.topic.clone().is_some().to_string();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
let topic = message.topic.clone().is_some().to_string();
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(),
Expand All @@ -524,6 +525,10 @@ impl DbClient for DdbClientImpl {
)
.await?;

self.metrics
.incr_with_tags("notification.message.stored")
.with_tag("topic", &topic)
.send();
Ok(())
}

Expand All @@ -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(())
}

Expand Down