Skip to content

Commit

Permalink
Add logs only mode for Watchdog integration. (mozilla-services#4926)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenba committed Sep 21, 2018
1 parent b7fd018 commit e685f83
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
8 changes: 8 additions & 0 deletions server/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,14 @@ const conf = convict({
env: "WATCHDOG_DEV_MATCH_HOSTNAME",
arg: "watchdog-dev-match-hostname",
},
// The logs only mode is to be removed in #4936.
logsOnly: {
doc: "This should be temporary. When true, Screenshots will only log Watchdog results.",
format: Boolean,
default: true,
env: "WATCHDOG_LOGS_ONLY",
arg: "watchdog-logs-only",
},
},
});

Expand Down
17 changes: 16 additions & 1 deletion server/src/watchdog.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,26 @@ exports.handleResult = function(req) {

function handleNegative(record) {
mozlog.debug("watchdog-negative-match", {msg: `Watchdog submission ${record.id} is a negative match.`});

if (config.watchdog.logsOnly) {
return null;
}

return db.update("UPDATE watchdog_submissions SET positive_result = FALSE WHERE id = $1", [record.id]);
}

function handlePositive(record) {
mozlog.info("watchdog-positive-match", {msg: `Watchdog submission ${record.id} is a positive match.`});
mozlog.info(
"watchdog-positive-match", {
msg: `Watchdog submission for shot ${record.shot_id} is a positive match.`,
watchdogId: record.request_id,
watchdogSubmissionId: record.id,
});

if (config.watchdog.logsOnly) {
return null;
}

return db.transaction(client => {
return db.queryWithClient(
client,
Expand Down

0 comments on commit e685f83

Please # to comment.