Skip to content

Commit

Permalink
making values array empty in each scrape
Browse files Browse the repository at this point in the history
  • Loading branch information
Saurabh Singh authored and Saurabh Singh committed May 31, 2024
1 parent 7879114 commit 49da0d9
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 9 deletions.
1 change: 0 additions & 1 deletion lib/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ class AggregatorRegistry extends Registry {

// Aggregate gathered metrics.
metricsByName.forEach(metrics => {
metrics.workerSize = metricsArr.length;
const aggregatorName = metrics[0].aggregator;
const aggregatorFn = aggregators[aggregatorName];
if (typeof aggregatorFn !== 'function') {
Expand Down
7 changes: 2 additions & 5 deletions lib/metricAggregators.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ function AggregatorFactory(aggregatorFn) {
if (!valuesArray) {
byLabels.set(value.hash, [value]);
} else {
if (valuesArray.length < metrics.workerSize) {
valuesArray.push(value);
} else {
byLabels.set(value.hash, [value]);
}
valuesArray.push(value);
}
});
});
Expand All @@ -48,6 +44,7 @@ function AggregatorFactory(aggregatorFn) {
}
// NB: Timestamps are omitted.
result.values.push(valObj);
values.length = 0;
});
return result;
};
Expand Down
3 changes: 0 additions & 3 deletions test/aggregatorsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ describe('aggregators', () => {
},
];

metrics.workerSize = 2;

describe('sum', () => {
it('properly sums values', () => {
const result = aggregators.sum(metrics);
Expand Down Expand Up @@ -119,7 +117,6 @@ describe('aggregators', () => {
values: [{ labels: [], value: 5, metricName: 'def', hash: 'h2' }],
},
];
metrics2.workerSize = 2;
const result = aggregators.sum(metrics2);
expect(result.values).toEqual([
{ value: 4, labels: [], metricName: 'abc' },
Expand Down

0 comments on commit 49da0d9

Please sign in to comment.