@@ -12,6 +12,7 @@ const helper = require('./common/helper')
12
12
const ProcessorService = require ( './services/ProcessorService' )
13
13
14
14
const AWSXRay = require ( 'aws-xray-sdk' )
15
+ const segment = new AWSXRay . Segment ( 'legacy-challenge-processor' ) ;
15
16
16
17
// Start kafka consumer
17
18
logger . info ( 'Starting kafka consumer' )
@@ -57,7 +58,12 @@ const dataHandler = (messageSet, topic, partition) => Promise.each(messageSet, a
57
58
}
58
59
59
60
const ns = AWSXRay . getNamespace ( ) ;
61
+ console . log ( 'Running within context' , ns ) ;
60
62
ns . run ( async ( ) => {
63
+ console . log ( 'creating segment' ) ;
64
+ console . log ( 'created segment' ) ;
65
+ AWSXRay . setSegment ( segment ) ;
66
+ console . log ( 'set segment' ) ;
61
67
62
68
const { traceInformation : {
63
69
traceId,
@@ -69,18 +75,16 @@ const dataHandler = (messageSet, topic, partition) => Promise.each(messageSet, a
69
75
70
76
console . log ( 'tracing information' , traceId , parentSegmentId ) ;
71
77
72
- const segment = new AWSXRay . Segment ( 'legacy-challenge-processor' ) ;
73
-
74
78
if ( traceId ) {
75
79
segment . trace_id = traceId ;
76
80
segment . id = parentSegmentId ;
77
81
}
78
82
79
- AWSXRay . setSegment ( segment ) ;
80
83
81
84
// do not trust the message payload
82
85
// the message.payload will be replaced with the data from the API
83
86
try {
87
+ console . log ( 'Fetch challenge details' ) ;
84
88
const challengeUuid = _ . get ( messageJSON , 'payload.id' )
85
89
if ( _ . isEmpty ( challengeUuid ) ) {
86
90
segment . close ( ) ;
@@ -98,6 +102,7 @@ const dataHandler = (messageSet, topic, partition) => Promise.each(messageSet, a
98
102
}
99
103
100
104
try {
105
+ console . log ( 'Process challenge' )
101
106
await ProcessorService . processMessage ( messageJSON )
102
107
103
108
// logger.debug('Successfully processed message')
0 commit comments