Skip to content

Commit

Permalink
Merge pull request #58 from Financial-Times/cloudwatch-mk2
Browse files Browse the repository at this point in the history
CloudWatch sample window fix v2
  • Loading branch information
sjparkinson authored Mar 28, 2017
2 parents 8a0417b + 1309236 commit fce7a75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
9 changes: 3 additions & 6 deletions src/checks/cloudWatchThreshold.check.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ class CloudWatchThresholdCheck extends Check {
}

generateParams() {
// use a larger window when gathering stats with a 60s period, because
// CloudWatch can take its time with populating new datapoints.
let timeWindow = this.samplePeriod;
if(timeWindow === 60) {
timeWindow = 90;
}
// use a larger window when gathering stats, because CloudWatch
// can take its sweet time with populating new datapoints.
let timeWindow = this.samplePeriod * 1.5;
return {
EndTime: moment().toISOString(),
StartTime: moment().subtract(timeWindow, 'seconds').toISOString(),
Expand Down
8 changes: 4 additions & 4 deletions test/cloudWatchThreshold.check.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('CloudWatch Threshold Check', () => {
});
});

it('should be unhealty if below threshold', done => {
it('should be unhealthy if below threshold', done => {
cloudWatchMock = cloudWatchDatapointMock;
check = new Check(getCheckConfig({
threshold: 40
Expand All @@ -79,7 +79,7 @@ describe('CloudWatch Threshold Check', () => {
});
});

it('should be unhealty if above threshold', done => {
it('should be unhealthy if above threshold', done => {
cloudWatchMock = cloudWatchDatapointMock;
check = new Check(getCheckConfig({
threshold: 100,
Expand Down Expand Up @@ -178,7 +178,7 @@ describe('CloudWatch Threshold Check', () => {
});
});

it('should use a 300 second window for a 300 second period', (done) => {
it('should use a 450 second window for a 300 second period', (done) => {
cloudWatchMock = cloudWatchDatapointMock;
check = new Check(getCheckConfig({
samplePeriod: 300
Expand All @@ -187,7 +187,7 @@ describe('CloudWatch Threshold Check', () => {
setTimeout(() => {
let args = cloudWatchMock.firstCall.args[0];
let timeWindow = new Date(args.EndTime) - new Date(args.StartTime);
expect(timeWindow).to.equal(300 * 1000);
expect(timeWindow).to.equal(450 * 1000);
done();
});
});
Expand Down

0 comments on commit fce7a75

Please sign in to comment.