diff --git a/red/nodes/Node.js b/red/nodes/Node.js index 3070ec932..32096282c 100644 --- a/red/nodes/Node.js +++ b/red/nodes/Node.js @@ -99,7 +99,7 @@ Node.prototype.send = function(msg) { if (!msg._messageUuid) { msg._messageUuid = constructUniqueIdentifier(); } - this.metric(msg,"Node.prototype.send"); + this.metric("Node.prototype.send", msg); node = flows.get(this._wire); if (node) { node.receive(msg); @@ -137,14 +137,14 @@ Node.prototype.send = function(msg) { // overwriting any previously written uuid because a cloned // message is a different one clonedmsg._messageUuid = constructUniqueIdentifier(); - this.metric(clonedmsg,"Node.prototype.send",{parentuuid:msgs[k]._messageUuid}); + this.metric("Node.prototype.send",clonedmsg,msgs[k]._messageUuid); sendEvents.push({n:node,m:clonedmsg}); } else { // first msg sent so don't clone - if (msgs[k]._messageUuid === null) { + if (!msgs[k]._messageUuid) { msgs[k]._messageUuid = constructUniqueIdentifier(); } - this.metric(msgs[k],"Node.prototype.send"); + this.metric("Node.prototype.send", msgs[k]); sendEvents.push({n:node,m:msgs[k]}); msgSent = true; } @@ -168,7 +168,7 @@ Node.prototype.receive = function(msg) { if (!msg._messageUuid) { msg._messageUuid = constructUniqueIdentifier(); } - this.metric(msg,"Node.prototype.receive"); + this.metric("Node.prototype.receive",msg); this.emit("input", msg); }; @@ -197,12 +197,13 @@ Node.prototype.error = function(msg) { log_helper(this, 'error', msg); }; -Node.prototype.metric = function(msg, eventname, metrics) { - metrics = metrics || {}; +Node.prototype.metric = function(eventname, msg, metricValue) { + var metrics = {}; metrics.level = "metric"; metrics.nodeid = this.id; metrics.event = eventname; metrics.msguuid = msg._messageUuid; + metrics.metric = metricValue; Log.log(metrics); } diff --git a/test/red/nodes/Node_spec.js b/test/red/nodes/Node_spec.js index 4f7226e34..cbea66a59 100644 --- a/test/red/nodes/Node_spec.js +++ b/test/red/nodes/Node_spec.js @@ -379,9 +379,9 @@ describe('Node', function() { loginfo = msg; }); var msg = {payload:"foo", _messageUuid:"987654321"}; - n.metric(msg,"test.metric",{size:"15mb"}); - should.deepEqual({size:"15mb", level:"metric", nodeid:n.id, - event:"test.metric",msguuid:"987654321"}, loginfo); + n.metric("test.metric",msg,"15mb"); + should.deepEqual({level:"metric", nodeid:n.id, + event:"test.metric",msguuid:"987654321", metric:"15mb"}, loginfo); Log.log.restore(); done(); });