From af0c73720e5cfc104c36923672dafb7de348d2cc Mon Sep 17 00:00:00 2001 From: Bruce Sherrod Date: Thu, 25 Jun 2020 08:51:42 -0700 Subject: [PATCH] fix performance issue in processHistogramLabels() (#25813) --- public/app/plugins/datasource/prometheus/language_utils.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/public/app/plugins/datasource/prometheus/language_utils.ts b/public/app/plugins/datasource/prometheus/language_utils.ts index b8ccdebe4db..098f5909d4c 100644 --- a/public/app/plugins/datasource/prometheus/language_utils.ts +++ b/public/app/plugins/datasource/prometheus/language_utils.ts @@ -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 = 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 } }; };