Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 8043298

Browse files
committed
feat: add logs
1 parent 5b08cc1 commit 8043298

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/app.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const helper = require('./common/helper')
1212
const ProcessorService = require('./services/ProcessorService')
1313

1414
const AWSXRay = require('aws-xray-sdk')
15+
const segment = new AWSXRay.Segment('legacy-challenge-processor');
1516

1617
// Start kafka consumer
1718
logger.info('Starting kafka consumer')
@@ -57,7 +58,12 @@ const dataHandler = (messageSet, topic, partition) => Promise.each(messageSet, a
5758
}
5859

5960
const ns = AWSXRay.getNamespace();
61+
console.log('Running within context', ns);
6062
ns.run(async () => {
63+
console.log('creating segment');
64+
console.log('created segment');
65+
AWSXRay.setSegment(segment);
66+
console.log('set segment');
6167

6268
const { traceInformation: {
6369
traceId,
@@ -69,18 +75,16 @@ const dataHandler = (messageSet, topic, partition) => Promise.each(messageSet, a
6975

7076
console.log('tracing information', traceId, parentSegmentId);
7177

72-
const segment = new AWSXRay.Segment('legacy-challenge-processor');
73-
7478
if (traceId) {
7579
segment.trace_id = traceId;
7680
segment.id = parentSegmentId;
7781
}
7882

79-
AWSXRay.setSegment(segment);
8083

8184
// do not trust the message payload
8285
// the message.payload will be replaced with the data from the API
8386
try {
87+
console.log('Fetch challenge details');
8488
const challengeUuid = _.get(messageJSON, 'payload.id')
8589
if (_.isEmpty(challengeUuid)) {
8690
segment.close();
@@ -98,6 +102,7 @@ const dataHandler = (messageSet, topic, partition) => Promise.each(messageSet, a
98102
}
99103

100104
try {
105+
console.log('Process challenge')
101106
await ProcessorService.processMessage(messageJSON)
102107

103108
// logger.debug('Successfully processed message')

0 commit comments

Comments
 (0)