Skip to content

Commit

Permalink
Merge pull request #158 from Financial-Times/log-null-data-in-graphit…
Browse files Browse the repository at this point in the history
…ethreshold-check

[NOPS-985] Log null data in GraphiteThreshold check
  • Loading branch information
alexmuller authored Sep 1, 2021
2 parents b0cc8e3 + 3ae482e commit a8a714f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/checks/graphiteThreshold.check.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class GraphiteThresholdCheck extends Check {
if (value[0] === null) {
// metric data is unavailable, we don't fail this threshold check if metric data is unavailable
// if you want a failing check for when metric data is unavailable, use graphiteWorking
logger.info({
event: `${logEventPrefix}_NULL_DATA`,
url: this.sampleUrl,
});
return false;
} else {
return this.direction === 'above' ?
Expand Down
12 changes: 11 additions & 1 deletion test/graphiteThreshold.check.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ function getCheckConfig (conf) {
return Object.assign({}, fixture, conf || {});
}

const mockLogger = {
default: {
error: function() {},
info: function() {},
}
}

let mockFetch;
let Check;

Expand All @@ -21,7 +28,10 @@ function mockGraphite (results) {
json : () => Promise.resolve(results)
}));

Check = proxyquire('../src/checks/graphiteThreshold.check', {'node-fetch':mockFetch});
Check = proxyquire('../src/checks/graphiteThreshold.check', {
'@financial-times/n-logger': mockLogger,
'node-fetch': mockFetch,
});
}

describe('Graphite Threshold Check', function(){
Expand Down

0 comments on commit a8a714f

Please sign in to comment.