Skip to content

Commit

Permalink
feat(fargate): emit phaseStarted and phaseCompleted events to cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardobridge committed Feb 6, 2024
1 parent cc71c23 commit 22d4928
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/artillery/lib/platform/aws-ecs/legacy/run-cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -1906,6 +1906,14 @@ async function listen(context, ee) {
ee.emit('stats', stats);
});

r.on('phaseStarted', (phase) => {
global.artillery.globalEvents.emit('phaseStarted', phase);
});

r.on('phaseCompleted', (phase) => {
global.artillery.globalEvents.emit('phaseCompleted', phase);
});

r.start();
});
}
Expand Down
25 changes: 25 additions & 0 deletions packages/artillery/lib/platform/aws-ecs/legacy/sqs-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class SqsReporter extends EventEmitter {
this.metricsByPeriod = {}; // individual intermediates by worker
this.mergedPeriodMetrics = []; // merged intermediates for a period

this.phaseStartedEventsSeen = {};
this.phaseCompletedEventsSeen = {};

// Debug info:
this.messagesProcessed = {};
this.metricsMessagesFromWorkers = {};
Expand Down Expand Up @@ -187,6 +190,28 @@ class SqsReporter extends EventEmitter {
return;
}

if (body.event === 'phaseStarted') {
if (
typeof self.phaseStartedEventsSeen[body.phase.index] === 'undefined'
) {
self.phaseStartedEventsSeen[body.phase.index] = Date.now();
self.emit(body.event, body.phase);
}

return;
}

if (body.event === 'phaseCompleted') {
if (
typeof self.phaseCompletedEventsSeen[body.phase.index] === 'undefined'
) {
self.phaseCompletedEventsSeen[body.phase.index] = Date.now();
self.emit(body.event, body.phase);
}

return;
}

// 'done' event is from SQS Plugin - unused for now
if (body.event === 'done') {
return;
Expand Down

0 comments on commit 22d4928

Please sign in to comment.