prometheus: monaco: autocomplete: offer function-names in functions (#41212)

pull/41253/head
Gábor Farkas 4 years ago committed by GitHub
parent 244e149c34
commit 72ae3235fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      public/app/plugins/datasource/prometheus/components/monaco-query-field/monaco-completion-provider/completions.ts

@ -47,6 +47,11 @@ const FUNCTION_COMPLETIONS: Completion[] = FUNCTIONS.map((f) => ({
documentation: f.documentation,
}));
async function getAllFunctionsAndMetricNamesCompletions(dataProvider: DataProvider): Promise<Completion[]> {
const metricNames = await getAllMetricNamesCompletions(dataProvider);
return [...FUNCTION_COMPLETIONS, ...metricNames];
}
const DURATION_COMPLETIONS: Completion[] = [
'$__interval',
'$__range',
@ -144,10 +149,9 @@ export async function getCompletions(situation: Situation, dataProvider: DataPro
case 'IN_DURATION':
return DURATION_COMPLETIONS;
case 'IN_FUNCTION':
return getAllMetricNamesCompletions(dataProvider);
return getAllFunctionsAndMetricNamesCompletions(dataProvider);
case 'AT_ROOT': {
const metricNames = await getAllMetricNamesCompletions(dataProvider);
return [...FUNCTION_COMPLETIONS, ...metricNames];
return getAllFunctionsAndMetricNamesCompletions(dataProvider);
}
case 'EMPTY': {
const metricNames = await getAllMetricNamesCompletions(dataProvider);

Loading…
Cancel
Save