1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Changing metric logging to take a primative rather than an object

This commit is contained in:
hbeeken 2015-02-03 13:51:05 +00:00 committed by Nick O'Leary
parent b052324d36
commit 7d6ce1ec12
2 changed files with 11 additions and 10 deletions

View File

@ -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);
}

View File

@ -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();
});