Permalink
Browse files

Fix timestamps

  • Loading branch information...
felixge committed Nov 18, 2011
1 parent c5195d7 commit f04260a1b7f3a9742847384e3adeab7cd02fae65
Showing with 7 additions and 3 deletions.
  1. +1 −0 lib/GraphiteClient.js
  2. +6 −3 test/integration/test-send.js
View
@@ -35,6 +35,7 @@ GraphiteClient.prototype.write = function(metrics, timestamp, cb) {
}
timestamp = timestamp || Date.now();
+ timestamp = Math.floor(timestamp / 1000);
this._carbon.write(GraphiteClient.flatten(metrics), timestamp, cb);
};
@@ -27,16 +27,19 @@ process.on('exit', function() {
var metric = server.metrics.shift();
assert.equal(metric.path, 'foo');
assert.equal(metric.value, 1);
- assert.ok(metric.timestamp + 1000 >= Date.now());
+ assert.ok(metric.timestamp + 1 >= Date.now() / 1000);
+ assert.ok(metric.timestamp - 1 <= Date.now() / 1000);
metric = server.metrics.shift();
assert.equal(metric.path, 'deep.down.a');
assert.equal(metric.value, 2);
- assert.ok(metric.timestamp + 1000 >= Date.now());
+ assert.ok(metric.timestamp + 1 >= Date.now() / 1000);
+ assert.ok(metric.timestamp - 1 <= Date.now() / 1000);
metric = server.metrics.shift();
assert.equal(metric.path, 'deep.down.b');
assert.equal(metric.value, 3);
- assert.ok(metric.timestamp + 1000 >= Date.now());
+ assert.ok(metric.timestamp + 1 >= Date.now() / 1000);
+ assert.ok(metric.timestamp - 1 <= Date.now() / 1000);
});

0 comments on commit f04260a

Please sign in to comment.