Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.30.4. #264

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# Changelog

### v2.30.4

* Use `Object.create(null)` rather than object initializer notation when initializing objects to store metric data.

### v2.30.3

* Ensure error strings are encapsulated in an `Error`-like object for transmission to the APM server.

### v2.30.2

Fix [#144](https://github.com/meteorhacks/kadira/issues/144).
* Fix [#144](https://github.com/meteorhacks/kadira/issues/144).

### v2.30.0

Expand Down
4 changes: 2 additions & 2 deletions lib/client/models/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ErrorModel = function(options) {

// errorsSentCount will be reseted at the start of the interval
self.errorsSentCount = 0;
self.errorsSent = {};
self.errorsSent = Object.create(null);
self.intervalTimeoutHandler = setInterval(function() {
self.errorsSentCount = 0;
self._flushErrors();
Expand Down Expand Up @@ -73,7 +73,7 @@ ErrorModel.prototype._flushErrors = function() {
if(errors.length > 0) {
Kadira.send({errors: errors}, '/errors');
}
self.errorsSent = {};
self.errorsSent = Object.create(null);
};

ErrorModel.prototype.isErrorExists = function(name) {
Expand Down
4 changes: 2 additions & 2 deletions lib/hijack/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ hijackDBOps = function hijackDBOps() {
var originalFunc = cursorProto[type];
cursorProto[type] = function() {
var cursorDescription = this._cursorDescription;
var payload = {
var payload = Object.assign(Object.create(null), {
coll: cursorDescription.collectionName,
selector: JSON.stringify(cursorDescription.selector),
func: type,
cursor: true
};
});

if(cursorDescription.options) {
var cursorOptions = _.pick(cursorDescription.options, ['fields', 'sort', 'limit']);
Expand Down
6 changes: 5 additions & 1 deletion lib/hijack/wrap_subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ wrapSubscription = function(subscriptionProto) {

var originalError = subscriptionProto.error;
subscriptionProto.error = function(err) {
if (typeof err === 'string') {
err = { message: err };
}

var kadiraInfo = Kadira._getInfo();

if(kadiraInfo && this._subscriptionId == kadiraInfo.trace.id) {
Expand Down Expand Up @@ -91,4 +95,4 @@ wrapSubscription = function(subscriptionProto) {
return res;
};
});
};
};
12 changes: 6 additions & 6 deletions lib/models/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ var METHOD_METRICS_FIELDS = ['wait', 'db', 'http', 'email', 'async', 'compute',
MethodsModel = function (metricsThreshold) {
var self = this;

this.methodMetricsByMinute = {};
this.errorMap = {};
this.methodMetricsByMinute = Object.create(null);
this.errorMap = Object.create(null);

this._metricsThreshold = _.extend({
"wait": 100,
Expand All @@ -14,10 +14,10 @@ MethodsModel = function (metricsThreshold) {
"async": 100,
"compute": 100,
"total": 200
}, metricsThreshold || {});
}, metricsThreshold || Object.create(null));

//store max time elapsed methods for each method, event(metrics-field)
this.maxEventTimesForMethods = {};
this.maxEventTimesForMethods = Object.create(null);

this.tracerStore = new TracerStore({
interval: 1000 * 60, //process traces every minute
Expand All @@ -35,7 +35,7 @@ MethodsModel.prototype._getMetrics = function(timestamp, method) {

if(!this.methodMetricsByMinute[dateId]) {
this.methodMetricsByMinute[dateId] = {
methods: {}
methods: Object.create(null),
};
}

Expand Down Expand Up @@ -124,7 +124,7 @@ MethodsModel.prototype.buildPayload = function(buildDetailedInfo) {

//handling metrics
var methodMetricsByMinute = this.methodMetricsByMinute;
this.methodMetricsByMinute = {};
this.methodMetricsByMinute = Object.create(null);

//create final paylod for methodMetrics
for(var key in methodMetricsByMinute) {
Expand Down
22 changes: 11 additions & 11 deletions lib/models/pubsub.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var logger = Npm.require('debug')('kadira:pubsub');

PubsubModel = function() {
this.metricsByMinute = {};
this.subscriptions = {};
this.metricsByMinute = Object.create(null);
this.subscriptions = Object.create(null);

this.tracerStore = new TracerStore({
interval: 1000 * 60, //process traces every minute
Expand Down Expand Up @@ -111,7 +111,7 @@ PubsubModel.prototype._getMetrics = function(timestamp, publication) {
this.metricsByMinute[dateId] = {
// startTime needs to be convert to serverTime before sending to the server
startTime: timestamp,
pubs: {}
pubs: Object.create(null)
};
}

Expand Down Expand Up @@ -155,20 +155,20 @@ PubsubModel.prototype._getPublicationName = function(name) {

PubsubModel.prototype._getSubscriptionInfo = function() {
var self = this;
var activeSubs = {};
var activeDocs = {};
var totalDocsSent = {};
var totalDataSent = {};
var totalObservers = {};
var cachedObservers = {};
var activeSubs = Object.create(null);
var activeDocs = Object.create(null);
var totalDocsSent = Object.create(null);
var totalDataSent = Object.create(null);
var totalObservers = Object.create(null);
var cachedObservers = Object.create(null);

for(var sessionId in Meteor.default_server.sessions) {
var session = Meteor.default_server.sessions[sessionId];
_.each(session._namedSubs, countSubData);
_.each(session._universalSubs, countSubData);
}

var avgObserverReuse = {};
var avgObserverReuse = Object.create(null);
_.each(totalObservers, function(value, publication) {
avgObserverReuse[publication] = cachedObservers[publication] / totalObservers[publication];
});
Expand Down Expand Up @@ -209,7 +209,7 @@ PubsubModel.prototype._getSubscriptionInfo = function() {

PubsubModel.prototype.buildPayload = function(buildDetailInfo) {
var metricsByMinute = this.metricsByMinute;
this.metricsByMinute = {};
this.metricsByMinute = Object.create(null);

var payload = {
pubMetrics: []
Expand Down
10 changes: 5 additions & 5 deletions lib/tracer/tracer_store.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ TracerStore = function TracerStore(options) {
this.archiveEvery = options.archiveEvery || this.maxTotalPoints / 6;

//store max total on the past 30 minutes (or past 30 items)
this.maxTotals = {};
this.maxTotals = Object.create(null);
//store the max trace of the current interval
this.currentMaxTrace = {};
this.currentMaxTrace = Object.create(null);
//archive for the traces
this.traceArchive = [];

this.processedCnt = {};
this.processedCnt = Object.create(null);

//group errors by messages between an interval
this.errorMap = {};
this.errorMap = Object.create(null);
};

TracerStore.prototype.addTrace = function(trace) {
Expand Down Expand Up @@ -106,7 +106,7 @@ TracerStore.prototype.processTraces = function() {
});

//reset the errorMap
self.errorMap = {};
self.errorMap = Object.create(null);
};

TracerStore.prototype._isTraceOutlier = function(kind, trace) {
Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
"summary": "Performance Monitoring for Meteor",
"version": "2.30.2",
"version": "2.30.4",
"git": "https://github.com/meteorhacks/kadira.git",
"name": "meteorhacks:kadira"
});
Expand Down