Make histogram options configurable from `init` and `BufferedMetricsLogger` constructor
Mr0grog opened this issue · 0 comments
Mr0grog commented
In #64, options were added to histograms for changing the percentiles and aggregations that it generates. However, these have to be specified on each call to histogram()
. If you want to adjust them for all metrics you send you have to a hacky workaround:
const metrics = new BufferedMetricsLogger();
const originalHistogram = metrics.histogram;
metrics.histogram = function (key, value, tags, timestamp, options = {}) {
options.aggregates ||= ["max", "avg", "count"];
options.percentiles ||= [0.95];
return originalHistogram.call(this, key, value, tags, timestamp, options);
});
Instead, it would be better if you could:
const metrics = new BufferedMetricsLogger({
histogram: {
aggregates: ["max", "avg", "count"],
percentiles: [0.95]
}
});
I’m not tied to the name of the option (histogram
), just that it has the same properties the options
argument on calls to histogram
does.