fix: data trails ignore usage syntax (#84610)

This commit is contained in:
Darren Janeczek 2024-03-15 15:27:31 -04:00 committed by GitHub
parent 08f4aeded1
commit 59baa7a4a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -14,13 +14,13 @@ describe('getPreviewPanelFor', () => {
}
test('When there are no filters, replace the ${filters} variable', () => {
const expected = "avg(${metric}{__ignore_usage__=''})";
const expected = 'avg(${metric}{__ignore_usage__=""})';
const expr = callAndGetExpr(0);
expect(expr).toStrictEqual(expected);
});
test('When there are 1 or more filters, append to the ${filters} variable', () => {
const expected = "avg(${metric}{${filters},__ignore_usage__=''})";
const expected = 'avg(${metric}{${filters},__ignore_usage__=""})';
for (let i = 1; i < 10; ++i) {
const expr = callAndGetExpr(1);

View File

@ -37,7 +37,7 @@ export function getPreviewPanelFor(metric: string, index: number, currentFilterC
function convertPreviewQueriesToIgnoreUsage(query: PromQuery, currentFilterCount: number) {
// If there are filters, we append to the list. Otherwise, we replace the empty list.
const replacement = currentFilterCount > 0 ? "${filters},__ignore_usage__=''" : "__ignore_usage__=''";
const replacement = currentFilterCount > 0 ? '${filters},__ignore_usage__=""' : '__ignore_usage__=""';
const expr = query.expr?.replace('${filters}', replacement);