Skip to content

Commit

Permalink
[PAWS][ENG-55567] Replace GCP collector npm library google-cloud-logg…
Browse files Browse the repository at this point in the history
…ing to googleapis integration testing small fixes (#376)
  • Loading branch information
imranalisyed506 authored Jul 16, 2024
1 parent 279bac0 commit 9b2a1d9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions collectors/googlestackdriver/collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,15 @@ timestamp < "${state.until}"`;
let logs = result.data.entries || [];
AlLogger.info(`Getting page: ${pagesRetireved + 1} Logs retrieved: ${logs.length}`);
pagesRetireved++;
const nextPage = { ...params, pageToken: result.data.nextPageToken };
const nextPageToken = result.data && result.data.nextPageToken ? result.data.nextPageToken : null;
let nextPage;
if (nextPageToken) {
nextPage = { ...params, filter: filter, pageToken: nextPageToken };
}
const newAcc = [...acc, ...logs];
AlLogger.info(`Total Logs ${newAcc.length}`);

if (nextPage.pageToken && pagesRetireved < process.env.paws_max_pages_per_invocation) {

return logging.entries.list(params)
if (nextPage && nextPage.pageToken && pagesRetireved < process.env.paws_max_pages_per_invocation) {
return logging.entries.list(nextPage)
.then(res => {
return paginationCallback(res, newAcc)
});
Expand All @@ -123,7 +125,7 @@ timestamp < "${state.until}"`;
};

const pageSize = state.pageSize > 0 ? state.pageSize : MAX_PAGE_SIZE;
let params = state.nextPage ?
let params = state.nextPage && state.nextPage.pageToken ?
state.nextPage :
{
filter,
Expand All @@ -134,10 +136,9 @@ timestamp < "${state.until}"`;
logging.entries.list(params)
.then(paginationCallback)
.then(({ logs, nextPage }) => {

const newState = collector._getNextCollectionState(state, nextPage);
AlLogger.debug(`GSTA000012 NextCollectionState ${JSON.stringify(newState)}`);
AlLogger.info(`GSTA000002 Next collection in ${newState.poll_interval_sec} seconds`);

return callback(null, logs, newState, newState.poll_interval_sec);
})
.catch(err => {
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.12",
"version": "1.2.13",
"description": "Alert Logic AWS based Googlestackdriver Log Collector",
"repository": {},
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion ps_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ stages:
- ./build_collector.sh googlestackdriver
env:
ALPS_SERVICE_NAME: "paws-googlestackdriver-collector"
ALPS_SERVICE_VERSION: "1.2.12" #set the value from collector package json
ALPS_SERVICE_VERSION: "1.2.13" #set the value from collector package json
outputs:
file: ./googlestackdriver-collector*
packagers:
Expand Down

0 comments on commit 9b2a1d9

Please sign in to comment.