Skip to content

Commit

Permalink
Merge pull request #749 from techmatters/SJH-reduce_log_spam
Browse files Browse the repository at this point in the history
Reduce log spam
  • Loading branch information
stephenhand authored Oct 1, 2024
2 parents 4edf1f5 + 993e01e commit fdda59b
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 20 deletions.
6 changes: 3 additions & 3 deletions hrm-domain/hrm-core/contact-job/contact-job-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ export const JOB_MAX_ATTEMPTS = 20;

export function processContactJobs() {
if (!processingJobs) {
console.log(
console.info(
`Started processing jobs every ${JOB_PROCESSING_INTERVAL_MILLISECONDS} milliseconds.`,
);
processingJobs = true;

return setInterval(async () => {
try {
console.debug(`processContactJobs sweep started.`);
// console.debug(`processContactJobs sweep started.`);
await pollAndProcessCompletedContactJobs(JOB_MAX_ATTEMPTS);
const now = new Date();
let dueContactJobs: ContactJob[] = [];
Expand All @@ -80,7 +80,7 @@ export function processContactJobs() {
}
});
await publishDueContactJobs(dueContactJobs);
console.debug(`processContactJobs sweep complete.`);
// console.debug(`processContactJobs sweep complete.`);
} catch (err) {
console.error(
new ContactJobPollerError(
Expand Down
4 changes: 2 additions & 2 deletions hrm-domain/hrm-core/contact-job/contact-job-publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const publishScrubTranscriptJob = async (
export const publishDueContactJobs = async (
dueContactJobs: ContactJob[],
): Promise<PromiseSettledResult<PublishedContactJobResult>[]> => {
console.debug(`Processing ${dueContactJobs?.length} due contact jobs.`);
// console.debug(`Processing ${dueContactJobs?.length} due contact jobs.`);
const publishedContactJobResult = await Promise.allSettled(
dueContactJobs.map(async (dueJob: ContactJob) => {
try {
Expand Down Expand Up @@ -127,7 +127,7 @@ export const publishDueContactJobs = async (
}
}),
);
console.debug(`Processed ${dueContactJobs?.length} due contact jobs.`);
// console.debug(`Processed ${dueContactJobs?.length} due contact jobs.`);

return publishedContactJobResult;
};
13 changes: 4 additions & 9 deletions lambdas/job-complete/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,16 @@
*/

import { CompletedJobProcessorError } from '@tech-matters/job-errors';
import { publishSns } from '@tech-matters/sns-client';

// eslint-disable-next-line prettier/prettier
import type { SQSBatchResponse, SQSEvent, SQSRecord } from 'aws-lambda';

const processRecord = async (sqsRecord: SQSRecord) => {
const processRecord = async ({ body, messageId, eventSource }: SQSRecord) => {
try {
const res = await publishSns({
message: sqsRecord.body,
topicArn: process.env.SNS_TOPIC_ARN || '',
});

console.log(res);
console.log('Completed processing message:', messageId, eventSource);
console.debug(`Message body:`, body);
} catch (err) {
console.error(new CompletedJobProcessorError('Failed to process record'), err);
console.error(new CompletedJobProcessorError('Failed to log completed record'), err);
}
};

Expand Down
1 change: 0 additions & 1 deletion lambdas/job-complete/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"dependencies": {
"@tech-matters/job-errors": "^1.0.0",
"@tech-matters/ssm-cache": "^1.0.0",
"@tech-matters/sns-client": "^1.0.0",
"@tech-matters/types": "^1.0.0"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion lambdas/job-complete/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
{ "path": "packages/types" },
{ "path": "packages/job-errors" },
{ "path": "packages/ssm-cache" },
{ "path": "packages/sns-client" },
{ "path": "lambdas/job-complete" }
]
}
2 changes: 0 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/elasticsearch-client/src/createIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const createIndex = async ({
}

const params = indexConfig.getCreateIndexParams(index);
console.log('Creating index', index, JSON.stringify(params, null, 2));
console.info('Creating index', index, JSON.stringify(params));
const res = await client.indices.create(params);

// This waits for the index to be created and for the shards to be allocated
Expand Down
2 changes: 1 addition & 1 deletion packages/elasticsearch-client/src/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const search = async <T>({
index,
searchParameters,
});
console.debug('search query', JSON.stringify(query, null, 2));
console.debug('search query', JSON.stringify(query));

const { hits } = await client.search(query);
const total = getTotalValue(hits.total);
Expand Down
2 changes: 2 additions & 0 deletions resources-domain/resources-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"es:delete-index:development": "cross-env NODE_ENV=development tsx ./scripts/elasticsearch/delete-index.ts",
"es:create-index:staging": "cross-env NODE_ENV=staging tsx ./scripts/elasticsearch/create-index.ts",
"es:delete-index:staging": "cross-env NODE_ENV=staging tsx ./scripts/elasticsearch/delete-index.ts",
"es:create-index:production": "cross-env NODE_ENV=production tsx ./scripts/elasticsearch/create-index.ts",
"es:delete-index:production": "cross-env NODE_ENV=production tsx ./scripts/elasticsearch/delete-index.ts",
"es:create-index:local": "cross-env AWS_REGION=us-east-1 SSM_ENDPOINT=http://localhost:4566 NODE_ENV=local ELASTICSEARCH_CONFIG_node=http://localhost:9200 tsx ./scripts/elasticsearch/create-index.ts",
"es:delete-index:local": "cross-env AWS_REGION=us-east-1 SSM_ENDPOINT=http://localhost:4566 NODE_ENV=local ELASTICSEARCH_CONFIG_node=http://localhost:9200 tsx ./scripts/elasticsearch/delete-index.ts",
"build-scripts": "tsc --project tsconfig.scripts.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ export const resourceService = () => {
({ id, name }) => resourceMap[id] ?? { id, name, _status: 'missing' },
);

// Monitors & dashboards use this log statement, review them before updating to ensure they remain aligned.
console.info(
`[resource-search] AccountSid: ${accountSid} - Search Complete. Total count from ES: ${total}, Paginated count from ES: ${items.length}, Paginated count from DB: ${unsortedResourceList.length}.`,
);

return {
results: orderedResults.map(record =>
isMissingResource(record) ? record : resourceRecordToApiResource(record),
Expand Down

0 comments on commit fdda59b

Please sign in to comment.