mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Tempo: Update lezer autocomplete (histogram, quantile) and add missing functions (#88131)
* Update version * Update autocomplete, add new functions * Update highlighting * Update yarn.lock
This commit is contained in:
parent
5f3cd4b900
commit
38fdfe43f5
@ -9,7 +9,7 @@
|
||||
"@grafana/e2e-selectors": "workspace:*",
|
||||
"@grafana/experimental": "1.7.11",
|
||||
"@grafana/lezer-logql": "0.2.3",
|
||||
"@grafana/lezer-traceql": "0.0.16",
|
||||
"@grafana/lezer-traceql": "0.0.17",
|
||||
"@grafana/monaco-logql": "^0.0.7",
|
||||
"@grafana/o11y-ds-frontend": "workspace:*",
|
||||
"@grafana/runtime": "workspace:*",
|
||||
|
@ -171,19 +171,19 @@ export class CompletionProvider implements monacoTypes.languages.CompletionItemP
|
||||
];
|
||||
|
||||
// Functions (aggregator, selector, and combining operators)
|
||||
static readonly spansetAggregatorOps: MinimalCompletionItem[] = [
|
||||
{
|
||||
label: 'count',
|
||||
insertText: 'count()$0',
|
||||
detail: 'Number of spans',
|
||||
documentation: 'Counts the number of spans in a spanset',
|
||||
},
|
||||
static readonly aggregatorFunctions: MinimalCompletionItem[] = [
|
||||
{
|
||||
label: 'avg',
|
||||
insertText: 'avg($0)',
|
||||
detail: 'Average of attribute',
|
||||
documentation: 'Computes the average of a given numeric attribute or intrinsic for a spanset.',
|
||||
},
|
||||
{
|
||||
label: 'count',
|
||||
insertText: 'count()$0',
|
||||
detail: 'Number of spans',
|
||||
documentation: 'Counts the number of spans in a spanset.',
|
||||
},
|
||||
{
|
||||
label: 'max',
|
||||
insertText: 'max($0)',
|
||||
@ -205,13 +205,37 @@ export class CompletionProvider implements monacoTypes.languages.CompletionItemP
|
||||
];
|
||||
|
||||
static readonly functions: MinimalCompletionItem[] = [
|
||||
...this.spansetAggregatorOps,
|
||||
...this.aggregatorFunctions,
|
||||
{
|
||||
label: 'by',
|
||||
insertText: 'by($0)',
|
||||
detail: 'Grouping of attributes',
|
||||
documentation: 'Groups by arbitrary attributes.',
|
||||
},
|
||||
{
|
||||
label: 'count_over_time',
|
||||
insertText: 'count_over_time()$0',
|
||||
detail: 'Number of spans over time',
|
||||
documentation: 'Counts the number of spans over time.',
|
||||
},
|
||||
{
|
||||
label: 'histogram_over_time',
|
||||
insertText: 'histogram_over_time($0)',
|
||||
detail: 'Histogram of attribute over time',
|
||||
documentation: 'Retrieves a histogram of an attributes values over time which are sorted into buckets.',
|
||||
},
|
||||
{
|
||||
label: 'quantile_over_time',
|
||||
insertText: 'quantile_over_time($0)',
|
||||
detail: 'Quantile of attribute over time',
|
||||
documentation: 'Retrieves one or more quantiles of an attributes numeric values over time.',
|
||||
},
|
||||
{
|
||||
label: 'rate',
|
||||
insertText: 'rate()$0',
|
||||
detail: 'Rate of spans',
|
||||
documentation: 'Counts the rate of spans per second.',
|
||||
},
|
||||
{
|
||||
label: 'select',
|
||||
insertText: 'select($0)',
|
||||
|
@ -58,11 +58,12 @@ export const computeErrorMessage = (errorNode: SyntaxNode) => {
|
||||
}
|
||||
case IntrinsicField:
|
||||
case Aggregate:
|
||||
if (errorNode.parent?.parent?.parent?.type.id === GroupOperation) {
|
||||
return 'Invalid expression for by operator.';
|
||||
} else if (errorNode.parent?.parent?.parent?.parent?.type.id === SelectOperation) {
|
||||
return 'Invalid expression for select operator.';
|
||||
}
|
||||
return 'Invalid expression for aggregator operator.';
|
||||
case GroupOperation:
|
||||
return 'Invalid expression for by operator.';
|
||||
case SelectOperation:
|
||||
return 'Invalid expression for select operator.';
|
||||
case AttributeField:
|
||||
return 'Invalid expression for spanset.';
|
||||
case ScalarFilter:
|
||||
|
@ -40,7 +40,15 @@ export const intrinsics = [
|
||||
];
|
||||
export const scopes: string[] = ['resource', 'span'];
|
||||
|
||||
export const functions = ['avg', 'min', 'max', 'sum', 'count', 'by'];
|
||||
const aggregatorFunctions = ['avg', 'count', 'max', 'min', 'sum'];
|
||||
const functions = aggregatorFunctions.concat([
|
||||
'by',
|
||||
'count_over_time',
|
||||
'histogram_over_time',
|
||||
'quantile_over_time',
|
||||
'rate',
|
||||
'select',
|
||||
]);
|
||||
|
||||
const keywords = intrinsics.concat(scopes);
|
||||
|
||||
|
10
yarn.lock
10
yarn.lock
@ -2871,7 +2871,7 @@ __metadata:
|
||||
"@grafana/e2e-selectors": "workspace:*"
|
||||
"@grafana/experimental": "npm:1.7.11"
|
||||
"@grafana/lezer-logql": "npm:0.2.3"
|
||||
"@grafana/lezer-traceql": "npm:0.0.16"
|
||||
"@grafana/lezer-traceql": "npm:0.0.17"
|
||||
"@grafana/monaco-logql": "npm:^0.0.7"
|
||||
"@grafana/o11y-ds-frontend": "workspace:*"
|
||||
"@grafana/plugin-configs": "npm:11.0.0"
|
||||
@ -3225,12 +3225,12 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@grafana/lezer-traceql@npm:0.0.16":
|
||||
version: 0.0.16
|
||||
resolution: "@grafana/lezer-traceql@npm:0.0.16"
|
||||
"@grafana/lezer-traceql@npm:0.0.17":
|
||||
version: 0.0.17
|
||||
resolution: "@grafana/lezer-traceql@npm:0.0.17"
|
||||
peerDependencies:
|
||||
"@lezer/lr": ^1.3.0
|
||||
checksum: 10/64443356f9ef880cbd2ccba7990c7a05d8eb73b165ef79d6ea55a269a775954a22262c3c90988dff82a21f4081dd8236ffe2c4af7c3ea41d03f7d994bea1af93
|
||||
checksum: 10/f9b32989ab5bab1f6407b1c83c4fd3169d589cd83d2abe95bcf68dca1ce1c512b923a0087dd010f528a202f47d102ae6dec81385f6a506632f23ece1e471a3df
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user