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

Enfore tabs as indentation #39

Merged
merged 2 commits into from
Sep 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
; http://editorconfig.org

root = true

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[package.json]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm rewrites this file all the time, should just keep it as spaces

indent_size = 2
indent_style = space

[*.md]
trim_trailing_whitespace = false
153 changes: 86 additions & 67 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,73 +1,92 @@
{
"env": {
"node": true
},
"globals": {
"node": true
},
"rules": {
"quotes": [
2,
"single"
],
"eol-last": [
0
],
"no-underscore-dangle": [
0
],
"no-mixed-requires": [
0
],
"key-spacing": [
0
],
"new-cap": [
0
],
"no-console": 2,
"no-debugger": 2,
"no-path-concat": 0,
"no-shadow": 1,
"semi": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-with": 2,
"no-loop-func": 2,
"no-multi-str": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-return-assign": 2,
"no-sequences": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-trailing-spaces": 2,
"no-unused-expressions": 2,
"no-use-before-define": 0,
"no-new": 0,
"curly": 2,
"dot-notation": [2, { "allowKeywords": true }],
"eqeqeq": 2,
"new-parens": 2,
"semi-spacing": 2,
"space-infix-ops": 2,
"keyword-spacing": ["error", { "overrides": {
"for": {
"after": false
},
"if": {
"after": false
},
"else": {
"after": true,
"before": true
}
}}],
"space-unary-ops": 2,
"strict": [2, "global"],
"yoda": 2,
"valid-jsdoc": 2
"indent": [
2,
"tab"
],
"quotes": [
2,
"single"
],
"eol-last": [
0
],
"no-underscore-dangle": [
0
],
"no-mixed-requires": [
0
],
"key-spacing": [
0
],
"new-cap": [
0
],
"no-console": 2,
"no-debugger": 2,
"no-path-concat": 0,
"no-shadow": 1,
"semi": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-with": 2,
"no-loop-func": 2,
"no-multi-str": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-return-assign": 2,
"no-sequences": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-trailing-spaces": 2,
"no-unused-expressions": 2,
"no-use-before-define": 0,
"no-new": 0,
"curly": 2,
"dot-notation": [
2,
{
"allowKeywords": true
}
],
"eqeqeq": 2,
"new-parens": 2,
"semi-spacing": 2,
"space-infix-ops": 2,
"keyword-spacing": [
"error",
{
"overrides": {
"for": {
"after": false
},
"if": {
"after": false
},
"else": {
"after": true,
"before": true
}
}
}
],
"space-unary-ops": 2,
"space-before-function-paren": [
2,
"never"
],
"strict": [
2,
"global"
],
"yoda": 2,
"valid-jsdoc": 2
}
}
60 changes: 30 additions & 30 deletions lib/defaultMetrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,46 @@ var processRequests = require('./metrics/processRequests');
var heapSizeAndUsed = require('./metrics/heapSizeAndUsed');

var metrics = {
processCpuTotal: processCpuTotal,
processStartTime: processStartTime,
osMemoryHeap: osMemoryHeap,
processOpenFileDescriptors: processOpenFileDescriptors,
processMaxFileDescriptors: processMaxFileDescriptors,
eventLoopLag: eventLoopLag,
processHandles: processHandles,
processRequests: processRequests,
heapSizeAndUsed: heapSizeAndUsed
processCpuTotal: processCpuTotal,
processStartTime: processStartTime,
osMemoryHeap: osMemoryHeap,
processOpenFileDescriptors: processOpenFileDescriptors,
processMaxFileDescriptors: processMaxFileDescriptors,
eventLoopLag: eventLoopLag,
processHandles: processHandles,
processRequests: processRequests,
heapSizeAndUsed: heapSizeAndUsed
};

var existingInterval = null;

module.exports = function startDefaultMetrics (disabledMetrics, interval) {
if(existingInterval !== null) {
clearInterval(existingInterval);
}
module.exports = function startDefaultMetrics(disabledMetrics, interval) {
if(existingInterval !== null) {
clearInterval(existingInterval);
}

disabledMetrics = disabledMetrics || [];
interval = interval || 10000;
disabledMetrics = disabledMetrics || [];
interval = interval || 10000;

var metricsInUse = Object.keys(metrics)
.filter(function (metric) {
return disabledMetrics.indexOf(metric) < 0;
})
.map(function (metric) {
return metrics[metric]();
});
var metricsInUse = Object.keys(metrics)
.filter(function(metric) {
return disabledMetrics.indexOf(metric) < 0;
})
.map(function(metric) {
return metrics[metric]();
});

function updateAllMetrics () {
metricsInUse.forEach(function (metric) {
metric.call();
});
}
function updateAllMetrics() {
metricsInUse.forEach(function(metric) {
metric.call();
});
}

updateAllMetrics();
updateAllMetrics();

existingInterval = setInterval(updateAllMetrics, interval).unref();
existingInterval = setInterval(updateAllMetrics, interval).unref();

return existingInterval;
return existingInterval;
};

module.exports.metricsList = Object.keys(metrics);
4 changes: 2 additions & 2 deletions lib/histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Histogram.prototype.get = function() {
var data = getProperties(this.hashMap);
var values =
data.map(extractBucketValuesForExport(this))
.reduce(addSumAndCountForExport(this), []);
.reduce(addSumAndCountForExport(this), []);

return {
name: this.name,
Expand Down Expand Up @@ -230,7 +230,7 @@ function addSumAndCountForExport(histogram) {
return function(acc, d) {
acc = acc.concat(d.buckets);

var infLabel = extend({ le: '+Inf'}, d.data.labels);
var infLabel = extend({ le: '+Inf' }, d.data.labels);
acc.push(createValuePair(infLabel, d.data.count, histogram.name + '_bucket'));
acc.push(createValuePair(d.data.labels, d.data.sum, histogram.name + '_sum'));
acc.push(createValuePair(d.data.labels, d.data.count, histogram.name + '_count'));
Expand Down
20 changes: 10 additions & 10 deletions lib/metrics/eventLoopLag.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

var Gauge = require('../gauge');

function reportEventloopLag(start, gauge){
var delta = process.hrtime(start);
var nanosec = delta[0] * 1e9 + delta[1];
var ms = nanosec / 1e6;
function reportEventloopLag(start, gauge) {
var delta = process.hrtime(start);
var nanosec = delta[0] * 1e9 + delta[1];
var ms = nanosec / 1e6;

gauge.set(Math.round(ms));
gauge.set(Math.round(ms));
}

module.exports = function() {
var gauge = new Gauge('node_eventloop_lag_milliseconds', 'Lag of event loop in milliseconds.');
var gauge = new Gauge('node_eventloop_lag_milliseconds', 'Lag of event loop in milliseconds.');

return function() {
var start = process.hrtime();
setImmediate(reportEventloopLag, start, gauge);
};
return function() {
var start = process.hrtime();
setImmediate(reportEventloopLag, start, gauge);
};
};
24 changes: 12 additions & 12 deletions lib/metrics/heapSizeAndUsed.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

var Gauge = require('../gauge');
module.exports = function() {
if(typeof process.memoryUsage !== 'function') {
return function () {
};
}
if(typeof process.memoryUsage !== 'function') {
return function() {
};
}

var heapSizeTotal = new Gauge('process_heap_size_node_bytes', 'Process heap size from node.js in bytes.');
var heapSizeUsed = new Gauge('process_heap_size_used_bytes', 'Process heap size used in bytes.');
var heapSizeTotal = new Gauge('process_heap_size_node_bytes', 'Process heap size from node.js in bytes.');
var heapSizeUsed = new Gauge('process_heap_size_used_bytes', 'Process heap size used in bytes.');

return function() {
var memUsage = process.memoryUsage();
heapSizeTotal.set(memUsage.heapTotal);
heapSizeUsed.set(memUsage.heapUsed);
return function() {
var memUsage = process.memoryUsage();
heapSizeTotal.set(memUsage.heapTotal);
heapSizeUsed.set(memUsage.heapUsed);

return { total: heapSizeTotal, used: heapSizeUsed };
};
return { total: heapSizeTotal, used: heapSizeUsed };
};
};
18 changes: 9 additions & 9 deletions lib/metrics/osMemoryHeap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

var Gauge = require('../gauge');
var linuxVariant = require('./osMemoryHeapLinux');
var notLinuxVariant = function () {
var residentMemGauge = new Gauge('process_resident_memory_bytes', 'Resident memory size in bytes.');
var notLinuxVariant = function() {
var residentMemGauge = new Gauge('process_resident_memory_bytes', 'Resident memory size in bytes.');

return function () {
var memoryUsage = process.memoryUsage();
return function() {
var memoryUsage = process.memoryUsage();

// I don't think the other things returned from `process.memoryUsage()` is relevant to a standard export
residentMemGauge.set(null, memoryUsage.rss);
};
// I don't think the other things returned from `process.memoryUsage()` is relevant to a standard export
residentMemGauge.set(null, memoryUsage.rss);
};
};

module.exports = function () {
return process.platform === 'linux' ? linuxVariant() : notLinuxVariant();
module.exports = function() {
return process.platform === 'linux' ? linuxVariant() : notLinuxVariant();
};