@onlineapps/conn-orch-orchestrator 1.0.44 → 1.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/WorkflowOrchestrator.js +52 -0
package/package.json
CHANGED
|
@@ -253,6 +253,34 @@ class WorkflowOrchestrator {
|
|
|
253
253
|
// Ignore - use default 0
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
+
// IMPORTANT: Publish progress event for FAILED step (so it appears in trace)
|
|
257
|
+
// This ensures every cookbook step is visible in monitoring, even failed ones
|
|
258
|
+
const { publishToMonitoringWorkflow } = require('@onlineapps/mq-client-core').monitoring;
|
|
259
|
+
try {
|
|
260
|
+
await publishToMonitoringWorkflow(this.mqClient, {
|
|
261
|
+
event_type: 'progress',
|
|
262
|
+
workflow_id: workflow_id,
|
|
263
|
+
service_name: serviceName,
|
|
264
|
+
step_index: failedStepIndex,
|
|
265
|
+
step_id: current_step,
|
|
266
|
+
cookbook: cookbookDef,
|
|
267
|
+
context: context,
|
|
268
|
+
output: null,
|
|
269
|
+
error: {
|
|
270
|
+
message: error.message,
|
|
271
|
+
attempt: attemptNumber
|
|
272
|
+
},
|
|
273
|
+
status: 'failed',
|
|
274
|
+
timestamp: new Date().toISOString()
|
|
275
|
+
}, this.logger, { workflow_id, step_id: current_step });
|
|
276
|
+
} catch (monitoringError) {
|
|
277
|
+
// Don't fail workflow if monitoring publish fails
|
|
278
|
+
this.logger.warn('Failed to publish failed step progress to monitoring', {
|
|
279
|
+
workflow_id,
|
|
280
|
+
error: monitoringError.message
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
|
|
256
284
|
// Add attempt to DLQ history
|
|
257
285
|
const attemptRecord = {
|
|
258
286
|
step_id: current_step,
|
|
@@ -340,6 +368,7 @@ class WorkflowOrchestrator {
|
|
|
340
368
|
error: error.stack
|
|
341
369
|
});
|
|
342
370
|
|
|
371
|
+
// Publish to workflow.failed (DLQ queue - message stays until manual requeue/discard)
|
|
343
372
|
await this.mqClient.publish('workflow.failed', {
|
|
344
373
|
workflow_id,
|
|
345
374
|
current_step,
|
|
@@ -354,6 +383,29 @@ class WorkflowOrchestrator {
|
|
|
354
383
|
failed_at: new Date().toISOString()
|
|
355
384
|
});
|
|
356
385
|
|
|
386
|
+
// ALSO publish to monitoring.workflow so dashboard shows the DLQ entry
|
|
387
|
+
// This is separate from the DLQ message - it's just for visibility
|
|
388
|
+
try {
|
|
389
|
+
await publishToMonitoringWorkflow(this.mqClient, {
|
|
390
|
+
event_type: 'failed',
|
|
391
|
+
workflow_id: workflow_id,
|
|
392
|
+
service_name: serviceName,
|
|
393
|
+
step_index: failedStepIndex,
|
|
394
|
+
step_id: current_step,
|
|
395
|
+
cookbook: cookbookDef,
|
|
396
|
+
context: finalContext,
|
|
397
|
+
error: { message: error.message },
|
|
398
|
+
status: 'failed',
|
|
399
|
+
timestamp: new Date().toISOString()
|
|
400
|
+
}, this.logger, { workflow_id, step_id: current_step });
|
|
401
|
+
} catch (monitoringError) {
|
|
402
|
+
// Don't fail if monitoring publish fails
|
|
403
|
+
this.logger.warn('[WorkflowOrchestrator] Failed to publish DLQ entry to monitoring', {
|
|
404
|
+
workflow_id,
|
|
405
|
+
error: monitoringError.message
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
|
|
357
409
|
console.log(`[WorkflowOrchestrator] [DLQ] ✓ Successfully published workflow.failed for ${workflow_id}`);
|
|
358
410
|
this.logger.info(`[WorkflowOrchestrator] [DLQ] ✓ Published workflow.failed: ${workflow_id}`);
|
|
359
411
|
} catch (publishError) {
|