Prometheus: Fix term completion that contain keywords (#21295)

- `unless`, `or` and `and` are binary operators
- if they appear in a query the query was broken up so the suggestor
only works on the current term
- this change fixes the splitter logic to make sure those keywords are
not inside a word
This commit is contained in:
David 2019-12-30 18:03:35 +01:00 committed by GitHub
parent 355b906493
commit 649fa6789e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -49,6 +49,7 @@ describe('Language completion provider', () => {
expect(cleanText('foo < bar')).toBe('bar');
expect(cleanText('foo >= bar')).toBe('bar');
expect(cleanText('foo <= bar')).toBe('bar');
expect(cleanText('memory')).toBe('memory');
});
it('removes aggregation syntax', () => {

View File

@ -51,7 +51,7 @@ function addMetricsMetadata(metric: string, metadata?: PromMetricsMetadata): Com
return item;
}
const PREFIX_DELIMITER_REGEX = /(="|!="|=~"|!~"|\{|\[|\(|\+|-|\/|\*|%|\^|and|or|unless|==|>=|!=|<=|>|<|=|~|,)/;
const PREFIX_DELIMITER_REGEX = /(="|!="|=~"|!~"|\{|\[|\(|\+|-|\/|\*|%|\^|\band\b|\bor\b|\bunless\b|==|>=|!=|<=|>|<|=|~|,)/;
export default class PromQlLanguageProvider extends LanguageProvider {
histogramMetrics?: string[];