зеркало из https://github.com/microsoft/statsd.git
put all histogram bins in a "histogram" sub-hierarchy
This commit is contained in:
Родитель
3fe3d43ae9
Коммит
7a9d9f3644
|
@ -82,6 +82,9 @@ var process_metrics = function (metrics, flushInterval, ts, flushCallback) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(bins.length) {
|
||||||
|
current_timer_data['histogram'] = {};
|
||||||
|
}
|
||||||
// the outer loop iterates bins, the inner loop iterates timer values;
|
// the outer loop iterates bins, the inner loop iterates timer values;
|
||||||
// within each run of the inner loop we should only consider the timer value range that's within the scope of the current bin
|
// within each run of the inner loop we should only consider the timer value range that's within the scope of the current bin
|
||||||
// so we leverage the fact that the values are already sorted to end up with only full 1 iteration of the entire values range
|
// so we leverage the fact that the values are already sorted to end up with only full 1 iteration of the entire values range
|
||||||
|
@ -92,7 +95,7 @@ var process_metrics = function (metrics, flushInterval, ts, flushCallback) {
|
||||||
freq += 1;
|
freq += 1;
|
||||||
}
|
}
|
||||||
bin_name = ('bin_' + bins[bin_i]).replace('.','_');
|
bin_name = ('bin_' + bins[bin_i]).replace('.','_');
|
||||||
current_timer_data[bin_name] = freq;
|
current_timer_data['histogram'][bin_name] = freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
timer_data[key] = current_timer_data;
|
timer_data[key] = current_timer_data;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
var pm = require('../lib/process_metrics')
|
var pm = require('../lib/process_metrics'),
|
||||||
|
_ = require('underscore');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
setUp: function (callback) {
|
setUp: function (callback) {
|
||||||
|
@ -118,7 +119,7 @@ module.exports = {
|
||||||
test.done();
|
test.done();
|
||||||
}, // check if the correct settings are being applied. as well as actual counts
|
}, // check if the correct settings are being applied. as well as actual counts
|
||||||
timers_histogram: function (test) {
|
timers_histogram: function (test) {
|
||||||
test.expect(45);
|
test.expect(13);
|
||||||
this.metrics.timers['a'] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
this.metrics.timers['a'] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||||
this.metrics.timers['abc'] = [0.1234, 2.89, 4, 6, 8];
|
this.metrics.timers['abc'] = [0.1234, 2.89, 4, 6, 8];
|
||||||
this.metrics.timers['foo'] = [0, 2, 4, 6, 8];
|
this.metrics.timers['foo'] = [0, 2, 4, 6, 8];
|
||||||
|
@ -132,41 +133,26 @@ module.exports = {
|
||||||
pm.process_metrics(this.metrics, 100, this.time_stamp, function(){});
|
pm.process_metrics(this.metrics, 100, this.time_stamp, function(){});
|
||||||
timer_data = this.metrics.timer_data;
|
timer_data = this.metrics.timer_data;
|
||||||
// nothing matches the 'abcd' config, so nothing has bin_5
|
// nothing matches the 'abcd' config, so nothing has bin_5
|
||||||
test.equal(undefined, timer_data['a']['bin_5']);
|
test.equal(undefined, timer_data['a']['histogram']['bin_5']);
|
||||||
test.equal(undefined, timer_data['abc']['bin_5']);
|
test.equal(undefined, timer_data['abc']['histogram']['bin_5']);
|
||||||
test.equal(undefined, timer_data['foo']['bin_5']);
|
|
||||||
test.equal(undefined, timer_data['barbazfoobar']['bin_5']);
|
|
||||||
test.equal(undefined, timer_data['bar.bazfoobar.abc']['bin_5']);
|
|
||||||
test.equal(undefined, timer_data['xyz']['bin_5']);
|
|
||||||
|
|
||||||
// check that 'a' got the right config and numbers
|
// check that 'a' got the right config and numbers
|
||||||
test.equal(0, timer_data['a']['bin_1']);
|
test.equal(0, timer_data['a']['histogram']['bin_1']);
|
||||||
test.equal(1, timer_data['a']['bin_2']);
|
test.equal(1, timer_data['a']['histogram']['bin_2']);
|
||||||
test.equal(undefined, timer_data['a']['bin_inf']);
|
test.equal(undefined, timer_data['a']['histogram']['bin_inf']);
|
||||||
|
|
||||||
// only 'abc' should have a bin_inf; also check all its counts,
|
// only 'abc' should have a bin_inf; also check all its counts,
|
||||||
// and make sure it has no other bins
|
// and make sure it has no other bins
|
||||||
// amount of non-bin_ keys: std, upper, lower, count, sum, mean -> 6
|
test.equal(1, timer_data['abc']['histogram']['bin_1']);
|
||||||
test.equal(1, timer_data['abc']['bin_1']);
|
test.equal(0, timer_data['abc']['histogram']['bin_2_21']);
|
||||||
test.equal(0, timer_data['abc']['bin_2_21']);
|
test.equal(4, timer_data['abc']['histogram']['bin_inf']);
|
||||||
test.equal(4, timer_data['abc']['bin_inf']);
|
test.equal(3, _.size(timer_data['abc']['histogram']));
|
||||||
for (key in timer_data['abc']) {
|
|
||||||
test.ok(key.indexOf('bin_') < 0 || key == 'bin_1' || key == 'bin_2_21' || key == 'bin_inf');
|
|
||||||
}
|
|
||||||
|
|
||||||
// 'foo', 'barbazfoobar' and 'bar.bazfoobar.meh' and 'xyz' should not have any bin
|
// these all have histograms disabled ('foo' explicitly, rest implicitly)
|
||||||
for (key in timer_data['foo']) {
|
test.equal(undefined, timer_data['foo']['histogram']);
|
||||||
test.ok(key.indexOf('bin_') < 0);
|
test.equal(undefined, timer_data['barbazfoobar']['histogram']);
|
||||||
}
|
test.equal(undefined, timer_data['bar.bazfoobar.abc']['histogram']);
|
||||||
for (key in timer_data['barbazfoobar']) {
|
test.equal(undefined, timer_data['xyz']['histogram']);
|
||||||
test.ok(key.indexOf('bin_') < 0);
|
|
||||||
}
|
|
||||||
for (key in timer_data['bar.bazfoobar.abc']) {
|
|
||||||
test.ok(key.indexOf('bin_') < 0);
|
|
||||||
}
|
|
||||||
for (key in timer_data['xyz']) {
|
|
||||||
test.ok(key.indexOf('bin_') < 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
test.done();
|
test.done();
|
||||||
},
|
},
|
||||||
|
|
Загрузка…
Ссылка в новой задаче