|
|
@ -38,6 +38,22 @@ function send(metric, points, extra, callback){ |
|
|
callback = extra; |
|
|
callback = extra; |
|
|
extra = {}; |
|
|
extra = {}; |
|
|
} |
|
|
} |
|
|
|
|
|
// Try to normalize `points`
|
|
|
|
|
|
// DEV: We need `points` to be an array of arrays regardless of what they give us
|
|
|
|
|
|
// Always wrap points in an array, this way we will get:
|
|
|
|
|
|
// 500 => [500]
|
|
|
|
|
|
// [<timestamp>, 500] => [[<timestamp>, 500]]
|
|
|
|
|
|
points = [points]; |
|
|
|
|
|
points = points.map(function(point){ |
|
|
|
|
|
// Make sure each point is an array, if not make array with current timestamp
|
|
|
|
|
|
// 500 => [<timestamp>, 500]
|
|
|
|
|
|
// [<timestamp>, 500] => unchanged
|
|
|
|
|
|
if(!Array.isArray(point)){ |
|
|
|
|
|
var now = parseInt(new Date().getTime() / 1000); |
|
|
|
|
|
point = [now, point]; |
|
|
|
|
|
} |
|
|
|
|
|
return point; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
extra = extra || {}; |
|
|
extra = extra || {}; |
|
|
var series = [ |
|
|
var series = [ |
|
|
|