Skip to content

Commit

Permalink
Set default timestamp when both timestamp and callback are ommitted
Browse files Browse the repository at this point in the history
Fixes #10
  • Loading branch information
HughePaul committed Mar 9, 2018
1 parent dfbdece commit 07aee8b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/GraphiteClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ GraphiteClient.appendTags = function(flatMetrics, tags) {
GraphiteClient.prototype.write = function(metrics, timestamp, cb) {
if (typeof timestamp === 'function') {
cb = timestamp;
timestamp = Date.now();
timestamp = null;
}

// default timestamp to now
timestamp = timestamp || Date.now();

// cutting timestamp for precision up to the second
timestamp = Math.floor(timestamp / 1000);

Expand Down

0 comments on commit 07aee8b

Please sign in to comment.