bugfix: allow bin upper limits to contain decimals

also modify an example to demonstrate
This commit is contained in:
Dieter Plaetinck 2012-11-05 16:03:16 -05:00
Родитель 50dd2ae684
Коммит 92c46c357a
3 изменённых файлов: 12 добавлений и 7 удалений

Просмотреть файл

@ -57,13 +57,13 @@ ordered non-inclusive upper limits of bins (class intervals).
(use `inf` to denote infinity; a lower limit of 0 is assumed) (use `inf` to denote infinity; a lower limit of 0 is assumed)
Each `flushInterval`, statsd will store how many values (absolute frequency) Each `flushInterval`, statsd will store how many values (absolute frequency)
fall within each bin (class interval), for all matching metrics. fall within each bin (class interval), for all matching metrics.
First match wins. examples: Examples:
* no histograms for any timer (default): `[]` * no histograms for any timer (default): `[]`
* histogram to only track render durations, * histogram to only track render durations,
with unequal class intervals and catchall for outliers: with unequal class intervals and catchall for outliers:
[ { metric: 'render', bins: [8, 25, 50, 100, 'inf'] } ] [ { metric: 'render', bins: [ 0.01, 0.1, 1, 10, 'inf'] } ]
* histogram for all timers except 'foo' related, * histogram for all timers except 'foo' related,
with equal class interval and catchall for outliers: with equal class interval and catchall for outliers:
@ -71,9 +71,13 @@ First match wins. examples:
[ { metric: 'foo', bins: [] }, [ { metric: 'foo', bins: [] },
{ metric: '', bins: [ 50, 100, 150, 200, 'inf'] } ] { metric: '', bins: [ 50, 100, 150, 200, 'inf'] } ]
Note that this is actually more powerful than what's strictly considered Note:
histograms, as you can make each bin arbitrarily wide if you want to
(upto infinity), i.e. class intervals of different sizes. * first match for a metric wins.
* bin upper limits may contain decimals.
* this is actually more powerful than what's strictly considered
histograms, as you can make each bin arbitrarily wide,
i.e. class intervals of different sizes.
Sampling Sampling
-------- --------

Просмотреть файл

@ -142,7 +142,8 @@ var flush_stats = function graphite_flush(ts, metrics) {
for (; i < count && (bins[bin_i] == 'inf' || values[i] < bins[bin_i]); i++) { for (; i < count && (bins[bin_i] == 'inf' || values[i] < bins[bin_i]); i++) {
freq += 1; freq += 1;
} }
message += 'stats.timers.' + key + '.bin_' + bins[bin_i] + ' ' + freq + ' ' + ts + "\n"; bin_name = ('bin_' + bins[bin_i]).replace('.','_');
message += 'stats.timers.' + key + '.' + bin_name + ' ' + freq + ' ' + ts + "\n";
} }
statString += message; statString += message;

Просмотреть файл

@ -59,7 +59,7 @@ Optional Variables:
First match wins. examples: First match wins. examples:
* histogram to only track render durations, with unequal * histogram to only track render durations, with unequal
class intervals and catchall for outliers: class intervals and catchall for outliers:
[ { metric: 'render', bins: [8, 25, 50, 100, 'inf'] } ] [ { metric: 'render', bins: [ 0.01, 0.1, 1, 10, 'inf'] } ]
* histogram for all timers except 'foo' related, * histogram for all timers except 'foo' related,
equal class interval and catchall for outliers: equal class interval and catchall for outliers:
[ { metric: 'foo', bins: [] }, [ { metric: 'foo', bins: [] },