From ba9baf5bb74ff2a0664311a64ef7fe971f00c740 Mon Sep 17 00:00:00 2001 From: Hassy Veldstra Date: Wed, 11 Oct 2023 16:28:42 +0100 Subject: [PATCH] fix: include original phase definition in phaseStarted/phaseCompleted events (#2203) --- packages/artillery/lib/launch-platform.js | 33 ++++++++++++++++------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/packages/artillery/lib/launch-platform.js b/packages/artillery/lib/launch-platform.js index 5a425fd4fb..aaddffb29b 100644 --- a/packages/artillery/lib/launch-platform.js +++ b/packages/artillery/lib/launch-platform.js @@ -97,11 +97,18 @@ class Launcher { typeof this.phaseStartedEventsSeen[message.phase.index] === 'undefined' ) { this.phaseStartedEventsSeen[message.phase.index] = Date.now(); - this.events.emit('phaseStarted', message.phase); - this.pluginEvents.emit('phaseStarted', message.phase); - this.pluginEventsLegacy.emit('phaseStarted', message.phase); - - global.artillery.globalEvents.emit('phaseStarted', message.phase); + const fullPhase = { + //get back original phase without any splitting for workers + ...this.script.config.phases[message.phase.index], + id: message.phase.id, + startTime: this.phaseStartedEventsSeen[message.phase.index] + }; + + this.events.emit('phaseStarted', fullPhase); + this.pluginEvents.emit('phaseStarted', fullPhase); + this.pluginEventsLegacy.emit('phaseStarted', fullPhase); + + global.artillery.globalEvents.emit('phaseStarted', fullPhase); } }); @@ -111,10 +118,18 @@ class Launcher { 'undefined' ) { this.phaseCompletedEventsSeen[message.phase.index] = Date.now(); - this.events.emit('phaseCompleted', message.phase); - this.pluginEvents.emit('phaseCompleted', message.phase); - this.pluginEventsLegacy.emit('phaseCompleted', message.phase); - global.artillery.globalEvents.emit('phaseCompleted', message.phase); + const fullPhase = { + //get back original phase without any splitting for workers + ...this.script.config.phases[message.phase.index], + id: message.phase.id, + startTime: this.phaseStartedEventsSeen[message.phase.index], + endTime: message.phase.endTime + }; + + this.events.emit('phaseCompleted', fullPhase); + this.pluginEvents.emit('phaseCompleted', fullPhase); + this.pluginEventsLegacy.emit('phaseCompleted', fullPhase); + global.artillery.globalEvents.emit('phaseCompleted', fullPhase); } });