Commit af0c7372 by Bruce Sherrod Committed by GitHub

fix performance issue in processHistogramLabels() (#25813)

parent 7f587b20
......@@ -4,17 +4,16 @@ import { addLabelToQuery } from './add_label_to_query';
export const RATE_RANGES = ['1m', '5m', '10m', '30m', '1h'];
export const processHistogramLabels = (labels: string[]) => {
const result = [];
const resultSet: Set<string> = new Set();
const regexp = new RegExp('_bucket($|:)');
for (let index = 0; index < labels.length; index++) {
const label = labels[index];
const isHistogramValue = regexp.test(label);
if (isHistogramValue) {
if (result.indexOf(label) === -1) {
result.push(label);
}
resultSet.add(label);
}
}
const result = [...resultSet];
return { values: { __name__: result } };
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment