Skip to content

Commit

Permalink
Merge branch 'master' into feat/spawn-tokenserver-pool-reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
ethowitz authored Apr 19, 2022
2 parents 9ad9d64 + 4c64c1c commit 02a2f12
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
11 changes: 5 additions & 6 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,11 @@ impl ApiError {

pub fn is_reportable(&self) -> bool {
// Should we report this error to sentry?
match self.kind() {
ApiErrorKind::Db(dbe) => return dbe.is_reportable(),
ApiErrorKind::Hawk(hawke) => return hawke.is_reportable(),
_ => (),
};
self.kind().metric_label().is_none()
self.status.is_server_error()
&& match self.kind() {
ApiErrorKind::Db(dbe) => dbe.is_reportable(),
_ => self.kind().metric_label().is_none(),
}
}

fn weave_error_code(&self) -> WeaveError {
Expand Down
6 changes: 3 additions & 3 deletions src/tokenserver/migrations/2021-07-16-001122_init/up.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
CREATE TABLE `services` (
CREATE TABLE IF NOT EXISTS `services` (
`id` int NOT NULL AUTO_INCREMENT,
`service` varchar(30) DEFAULT NULL,
`pattern` varchar(128) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `service` (`service`)
);

CREATE TABLE `nodes` (
CREATE TABLE IF NOT EXISTS `nodes` (
`id` bigint NOT NULL AUTO_INCREMENT,
`service` int NOT NULL,
`node` varchar(64) NOT NULL,
Expand All @@ -20,7 +20,7 @@ CREATE TABLE `nodes` (
CONSTRAINT `nodes_ibfk_1` FOREIGN KEY (`service`) REFERENCES `services` (`id`)
);

CREATE TABLE `users` (
CREATE TABLE IF NOT EXISTS `users` (
`uid` bigint NOT NULL AUTO_INCREMENT,
`service` int NOT NULL,
`email` varchar(255) NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
INSERT INTO services (id, service, pattern) VALUES
INSERT IGNORE INTO services (id, service, pattern) VALUES
(1, "sync-1.1", "{node}/1.1/{uid}"),
(2, "sync-1.5", "{node}/1.5/{uid}");
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
INSERT INTO services (id, service, pattern) VALUES
INSERT IGNORE INTO services (id, service, pattern) VALUES
(1, "sync-1.1", "{node}/1.1/{uid}"),
(2, "sync-1.5", "{node}/1.5/{uid}");
4 changes: 0 additions & 4 deletions src/web/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ impl HawkError {
&self.kind
}

pub fn is_reportable(&self) -> bool {
matches!(&self.kind(), HawkErrorKind::TruncatedId)
}

pub fn metric_label(&self) -> Option<String> {
match self.kind() {
HawkErrorKind::Base64(_) => Some("request.error.hawk.decode_error".to_owned()),
Expand Down

0 comments on commit 02a2f12

Please sign in to comment.