Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix timestamps

  • Loading branch information...
commit f04260a1b7f3a9742847384e3adeab7cd02fae65 1 parent c5195d7
@felixge authored
Showing with 7 additions and 3 deletions.
  1. +1 −0  lib/GraphiteClient.js
  2. +6 −3 test/integration/test-send.js
View
1  lib/GraphiteClient.js
@@ -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);
};
View
9 test/integration/test-send.js
@@ -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);
});
Please sign in to comment.
Something went wrong with that request. Please try again.