Skip to content

Commit

Permalink
handle the pagination state properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakhi Mundhada authored and Rakhi Mundhada committed Dec 21, 2023
1 parent 95467fe commit 6c852b7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
45 changes: 27 additions & 18 deletions collectors/googlestackdriver/collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,25 +161,34 @@ timestamp < "${state.until}"`;
}

_getNextCollectionState(curState, nextPage) {
// Reset the page size for next collection as log collection completed for throttling interval
if (nextPage && nextPage.pageSize && nextPage.pageSize < MAX_PAGE_SIZE) {
nextPage.pageSize = MAX_PAGE_SIZE;
} else if (curState.pageSize && curState.pageSize < MAX_PAGE_SIZE) {
curState.pageSize = MAX_PAGE_SIZE;
// Reset the page size for the next collection if it's less than the maximum
const pageSize = Math.max(MAX_PAGE_SIZE, nextPage?.pageSize || curState.pageSize || MAX_PAGE_SIZE);

const { stream, since, until } = curState;

if (nextPage) {
// Case: Continue with the next page
return {
since,
nextPage: { ...nextPage, pageSize },
stream,
until,
poll_interval_sec: 1
};
} else {
// Case: Start a new collection
const untilMoment = moment(curState.until);

const { nextUntilMoment, nextSinceMoment, nextPollInterval } = calcNextCollectionInterval('day-week-progression', untilMoment, this.pollInterval);

return {
since: nextSinceMoment.toISOString(),
nextPage,
stream,
until: nextUntilMoment.toISOString(),
poll_interval_sec: nextPollInterval
};
}
const {stream} = curState;

const untilMoment = moment(curState.until);

const { nextUntilMoment, nextSinceMoment, nextPollInterval } = calcNextCollectionInterval('day-week-progression', untilMoment, this.pollInterval);

return {
since: nextSinceMoment.toISOString(),
nextPage,
stream,
until: nextUntilMoment.toISOString(),
poll_interval_sec: nextPollInterval
};
}

// TODO: probably need to actually decode hte protobuf payload on these logs
Expand Down
2 changes: 1 addition & 1 deletion collectors/googlestackdriver/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "googlestackdriver-collector",
"version": "1.2.6",
"version": "1.2.7",
"description": "Alert Logic AWS based Googlestackdriver Log Collector",
"repository": {},
"private": true,
Expand Down

0 comments on commit 6c852b7

Please sign in to comment.