CloudWatch Logs: Change what we use to measure progress (#28912)

This commit is contained in:
Andrej Ocenas 2020-11-09 15:17:56 +01:00 committed by GitHub
parent f22d77100f
commit 76f4c11430
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -336,7 +336,7 @@ export class CloudWatchDatasource extends DataSourceApi<CloudWatchQuery, CloudWa
({ failures, prevRecordsMatched }, frames) => {
failures++;
for (const frame of frames) {
const recordsMatched = frame.meta?.stats?.find(stat => stat.displayName === 'Records matched')?.value!;
const recordsMatched = frame.meta?.stats?.find(stat => stat.displayName === 'Records scanned')?.value!;
if (recordsMatched > (prevRecordsMatched[frame.refId!] ?? 0)) {
failures = 0;
}

View File

@ -186,23 +186,23 @@ describe('CloudWatchDatasource', () => {
it('should stop querying when no more data received a number of times in a row', async () => {
const fakeFrames = genMockFrames(20);
const initialRecordsMatched = fakeFrames[0].meta!.stats!.find(stat => stat.displayName === 'Records matched')!
const initialRecordsMatched = fakeFrames[0].meta!.stats!.find(stat => stat.displayName === 'Records scanned')!
.value!;
for (let i = 1; i < 4; i++) {
fakeFrames[i].meta!.stats = [
{
displayName: 'Records matched',
displayName: 'Records scanned',
value: initialRecordsMatched,
},
];
}
const finalRecordsMatched = fakeFrames[9].meta!.stats!.find(stat => stat.displayName === 'Records matched')!
const finalRecordsMatched = fakeFrames[9].meta!.stats!.find(stat => stat.displayName === 'Records scanned')!
.value!;
for (let i = 10; i < fakeFrames.length; i++) {
fakeFrames[i].meta!.stats = [
{
displayName: 'Records matched',
displayName: 'Records scanned',
value: finalRecordsMatched,
},
];
@ -1198,7 +1198,7 @@ function genMockFrames(numResponses: number): DataFrame[] {
},
stats: [
{
displayName: 'Records matched',
displayName: 'Records scanned',
value: (i + 1) * recordIncrement,
},
],