Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #56 from BonnierNews/fix/logging-stuff
Browse files Browse the repository at this point in the history
Fix some logging
  • Loading branch information
MattiasOlla authored Jan 26, 2024
2 parents 3a042a9 + ddc8b2b commit d99df9a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions lib/message-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export default async function messageHandler(recipeMap, req, res) {

const { logger } = context;

logger.info(`incoming message ${JSON.stringify(messageData)}`);

const handleError = async (error) => {
if (error.rejected) {
logger.error(
Expand Down Expand Up @@ -98,13 +100,12 @@ export default async function messageHandler(recipeMap, req, res) {
return res.status(200).send();
}
} catch (err) {
logger.error(`Firebase error: ${JSON.stringify(err)}`);
logger.error(`Firestore error: ${err.code} ${err.message}`);
return res.status(502).send({ error: err });
}
}
metrics.messages.inc();

logger.info(`incoming message ${JSON.stringify(messageData)}`);
const parts = key.split(".");
const suffix = parts.pop();
const [ prefix ] = parts;
Expand Down
4 changes: 2 additions & 2 deletions lib/publish-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const pubSubClient = config.pubSub ? new PubSub({ apiEndpoint: config.pubSub.api
const cleanupAttributes = (attributes) => JSON.parse(JSON.stringify(attributes));

export default async function publishMessage(message, attributes) {
const logger = buildLogger(message.correlationId);
const logger = buildLogger(attributes.correlationId);
const messageId = await publishPubsubMessage(
pubSubClient.topic(config.topic),
{ json: message, attributes: cleanupAttributes({ ...attributes, topic: config.topic, idempotencyKey: uuid.v4() }) },
Expand All @@ -19,7 +19,7 @@ export default async function publishMessage(message, attributes) {
}

export async function rejectMessage(message, attributes) {
const logger = buildLogger(message.correlationId);
const logger = buildLogger(attributes.correlationId);
const messageId = await publishPubsubMessage(
pubSubClient.topic(config.deadLetterTopic),
{ json: message, attributes: cleanupAttributes({ ...attributes, topic: config.topic }) },
Expand Down
4 changes: 2 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 package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bonniernews/b0rker",
"version": "7.2.0",
"version": "7.2.1",
"engines": {
"node": ">=16"
},
Expand Down

0 comments on commit d99df9a

Please sign in to comment.