Permalink
Browse files

Make small changes based on pull request feedback

  • Loading branch information...
1 parent ec9cc25 commit c3d87eaa82724fece1a86ff273f28cffaeed91db @draco2003 committed Oct 13, 2012
@@ -64,14 +64,14 @@ var flush_stats = function graphite_flush(ts, metrics) {
var timer_data = metrics.timer_data;
for (key in counters) {
- statString += 'stats.' + key + ' ' + counter_rates[key] + ' ' + ts + "\n";
- statString += 'stats_counts.' + key + ' ' + counters[key] + ' ' + ts + "\n";
+ statString += 'stats.' + key + ' ' + counter_rates[key] + ' ' + ts + "\n";
+ statString += 'stats_counts.' + key + ' ' + counters[key] + ' ' + ts + "\n";
numStats += 1;
}
- for (key in timers) {
- if (timers[key].length > 0) {
+ for (key in timer_data) {
+ if (Object.keys(timer_data).length > 0) {
for (timer_data_key in timer_data[key]) {
statString += 'stats.timers.' + key + '.' + timer_data_key + ' ' + timer_data[key][timer_data_key] + ' ' + ts + "\n";
}
@@ -1,4 +1,4 @@
-var ProcessedMetrics = function (metrics, flushInterval) {
+var process_metrics = function (metrics, flushInterval) {
var starttime = Date.now();
var key;
var counter_rates = {};
@@ -85,4 +85,4 @@ var ProcessedMetrics = function (metrics, flushInterval) {
return metrics;
}
-exports.ProcessedMetrics = ProcessedMetrics
+exports.process_metrics = process_metrics
View
@@ -6,7 +6,7 @@ var dgram = require('dgram')
, events = require('events')
, logger = require('./lib/logger')
, set = require('./lib/set')
- , pm = require('./lib/processedmetrics')
+ , pm = require('./lib/process_metrics')
// initialize data structures with defaults for statsd stats
var keyCounter = {};
@@ -71,7 +71,7 @@ function flushMetrics() {
}
});
- metrics_hash = pm.ProcessedMetrics(metrics_hash, flushInterval)
+ metrics_hash = pm.process_metrics(metrics_hash, flushInterval)
// Flush metrics to each backend.
backendEvents.emit('flush', time_stamp, metrics_hash);
@@ -1,4 +1,4 @@
-var pm = require('../lib/processedmetrics')
+var pm = require('../lib/process_metrics')
var time_stamp = Math.round(new Date().getTime() / 1000);
var counters = {};
@@ -19,28 +19,28 @@ module.exports = {
counters_has_stats_count: function(test) {
test.expect(1);
metrics.counters['a'] = 2;
- var processed_metrics = new pm.ProcessedMetrics(metrics, 1000);
+ var processed_metrics = new pm.process_metrics(metrics, 1000);
test.equal(2, processed_metrics.counters['a']);
test.done();
},
counters_has_correct_rate: function(test) {
test.expect(1);
metrics.counters['a'] = 2;
- var processed_metrics = new pm.ProcessedMetrics(metrics, 100);
+ var processed_metrics = new pm.process_metrics(metrics, 100);
test.equal(20, processed_metrics.counter_rates['a']);
test.done();
},
timers_handle_empty: function(test) {
test.expect(1);
metrics.timers['a'] = [];
- var processed_metrics = new pm.ProcessedMetrics(metrics, 100);
+ var processed_metrics = new pm.process_metrics(metrics, 100);
test.equal(20, processed_metrics.counter_rates['a']);
test.done();
},
timers_single_time: function(test) {
test.expect(6);
metrics.timers['a'] = [100];
- var processed_metrics = new pm.ProcessedMetrics(metrics, 100);
+ var processed_metrics = new pm.process_metrics(metrics, 100);
timer_data = processed_metrics.timer_data['a'];
test.equal(0, timer_data.std);
test.equal(100, timer_data.upper);
@@ -53,7 +53,7 @@ module.exports = {
timers_multiple_times: function(test) {
test.expect(6);
metrics.timers['a'] = [100, 200, 300];
- var processed_metrics = new pm.ProcessedMetrics(metrics, 100);
+ var processed_metrics = new pm.process_metrics(metrics, 100);
timer_data = processed_metrics.timer_data['a'];
test.equal(81.64965809277261, timer_data.std);
test.equal(300, timer_data.upper);
@@ -67,7 +67,7 @@ module.exports = {
test.expect(3);
metrics.timers['a'] = [100];
metrics.pctThreshold = [90];
- var processed_metrics = new pm.ProcessedMetrics(metrics, 100);
+ var processed_metrics = new pm.process_metrics(metrics, 100);
timer_data = processed_metrics.timer_data['a'];
test.equal(100, timer_data.mean_90);
test.equal(100, timer_data.upper_90);
@@ -78,7 +78,7 @@ module.exports = {
test.expect(6);
metrics.timers['a'] = [100];
metrics.pctThreshold = [90, 80];
- var processed_metrics = new pm.ProcessedMetrics(metrics, 100);
+ var processed_metrics = new pm.process_metrics(metrics, 100);
timer_data = processed_metrics.timer_data['a'];
test.equal(100, timer_data.mean_90);
test.equal(100, timer_data.upper_90);
@@ -92,7 +92,7 @@ module.exports = {
test.expect(3);
metrics.timers['a'] = [100, 200, 300];
metrics.pctThreshold = [90];
- var processed_metrics = new pm.ProcessedMetrics(metrics, 100);
+ var processed_metrics = new pm.process_metrics(metrics, 100);
timer_data = processed_metrics.timer_data['a'];
test.equal(200, timer_data.mean_90);
test.equal(300, timer_data.upper_90);
@@ -103,7 +103,7 @@ module.exports = {
test.expect(6);
metrics.timers['a'] = [100, 200, 300];
metrics.pctThreshold = [90, 80];
- var processed_metrics = new pm.ProcessedMetrics(metrics, 100);
+ var processed_metrics = new pm.process_metrics(metrics, 100);
timer_data = processed_metrics.timer_data['a'];
test.equal(200, timer_data.mean_90);
test.equal(300, timer_data.upper_90);

0 comments on commit c3d87ea

Please sign in to comment.