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

(cherry picked from commit 76f4c11430)

Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2020-11-10 12:12:26 +01:00
committed by GitHub
co-authored by Andrej Ocenas
parent f9f3b9d953
commit 706cc59d1d
2 changed files with 6 additions and 6 deletions
@@ -245,7 +245,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;
}
@@ -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,
},
],