prometheus: monaco: do not recalculate not-changing function-list (#39406)

This commit is contained in:
Gábor Farkas
2021-09-20 13:24:55 +02:00
committed by GitHub
parent 8cdc752497
commit dc61edc8ac
@@ -39,15 +39,13 @@ async function getAllMetricNamesCompletions(dataProvider: DataProvider): Promise
})); }));
} }
function getAllFunctionsCompletions(): Completion[] { const FUNCTION_COMPLETIONS: Completion[] = FUNCTIONS.map((f) => ({
return FUNCTIONS.map((f) => ({ type: 'FUNCTION',
type: 'FUNCTION', label: f.label,
label: f.label, insertText: f.insertText ?? '', // i don't know what to do when this is nullish. it should not be.
insertText: f.insertText ?? '', // i don't know what to do when this is nullish. it should not be. detail: f.detail,
detail: f.detail, documentation: f.documentation,
documentation: f.documentation, }));
}));
}
const DURATION_COMPLETIONS: Completion[] = [ const DURATION_COMPLETIONS: Completion[] = [
'$__interval', '$__interval',
@@ -149,12 +147,12 @@ export async function getCompletions(intent: Intent, dataProvider: DataProvider)
return getAllMetricNamesCompletions(dataProvider); return getAllMetricNamesCompletions(dataProvider);
case 'FUNCTIONS_AND_ALL_METRIC_NAMES': { case 'FUNCTIONS_AND_ALL_METRIC_NAMES': {
const metricNames = await getAllMetricNamesCompletions(dataProvider); const metricNames = await getAllMetricNamesCompletions(dataProvider);
return [...getAllFunctionsCompletions(), ...metricNames]; return [...FUNCTION_COMPLETIONS, ...metricNames];
} }
case 'HISTORY_AND_FUNCTIONS_AND_ALL_METRIC_NAMES': { case 'HISTORY_AND_FUNCTIONS_AND_ALL_METRIC_NAMES': {
const metricNames = await getAllMetricNamesCompletions(dataProvider); const metricNames = await getAllMetricNamesCompletions(dataProvider);
const historyCompletions = await getAllHistoryCompletions(dataProvider); const historyCompletions = await getAllHistoryCompletions(dataProvider);
return [...historyCompletions, ...getAllFunctionsCompletions(), ...metricNames]; return [...historyCompletions, ...FUNCTION_COMPLETIONS, ...metricNames];
} }
case 'LABEL_NAMES_FOR_SELECTOR': case 'LABEL_NAMES_FOR_SELECTOR':
return getLabelNamesForSelectorCompletions(intent.metricName, intent.otherLabels, dataProvider); return getLabelNamesForSelectorCompletions(intent.metricName, intent.otherLabels, dataProvider);