mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix performance issue in processHistogramLabels() (#25813)
This commit is contained in:
parent
7f587b209f
commit
af0c73720e
@ -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 } };
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user