mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
prometheus: monaco: autocomplete: offer function-names in functions (#41212)
This commit is contained in:
parent
244e149c34
commit
72ae3235fa
@ -47,6 +47,11 @@ const FUNCTION_COMPLETIONS: Completion[] = FUNCTIONS.map((f) => ({
|
|||||||
documentation: f.documentation,
|
documentation: f.documentation,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
async function getAllFunctionsAndMetricNamesCompletions(dataProvider: DataProvider): Promise<Completion[]> {
|
||||||
|
const metricNames = await getAllMetricNamesCompletions(dataProvider);
|
||||||
|
return [...FUNCTION_COMPLETIONS, ...metricNames];
|
||||||
|
}
|
||||||
|
|
||||||
const DURATION_COMPLETIONS: Completion[] = [
|
const DURATION_COMPLETIONS: Completion[] = [
|
||||||
'$__interval',
|
'$__interval',
|
||||||
'$__range',
|
'$__range',
|
||||||
@ -144,10 +149,9 @@ export async function getCompletions(situation: Situation, dataProvider: DataPro
|
|||||||
case 'IN_DURATION':
|
case 'IN_DURATION':
|
||||||
return DURATION_COMPLETIONS;
|
return DURATION_COMPLETIONS;
|
||||||
case 'IN_FUNCTION':
|
case 'IN_FUNCTION':
|
||||||
return getAllMetricNamesCompletions(dataProvider);
|
return getAllFunctionsAndMetricNamesCompletions(dataProvider);
|
||||||
case 'AT_ROOT': {
|
case 'AT_ROOT': {
|
||||||
const metricNames = await getAllMetricNamesCompletions(dataProvider);
|
return getAllFunctionsAndMetricNamesCompletions(dataProvider);
|
||||||
return [...FUNCTION_COMPLETIONS, ...metricNames];
|
|
||||||
}
|
}
|
||||||
case 'EMPTY': {
|
case 'EMPTY': {
|
||||||
const metricNames = await getAllMetricNamesCompletions(dataProvider);
|
const metricNames = await getAllMetricNamesCompletions(dataProvider);
|
||||||
|
Loading…
Reference in New Issue
Block a user