From a62ec43d08bdf8ff71dee245349f6dd86993318d Mon Sep 17 00:00:00 2001 From: Vignesh Shanmugam Date: Mon, 12 Jul 2021 15:08:24 -0700 Subject: [PATCH] [Heartbeat]: capture error from journey/end events (#26781) (cherry picked from commit 11b545a182909de2234aed8bf2916f16f2234f5e) --- .../monitors/browser/synthexec/enrich.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/x-pack/heartbeat/monitors/browser/synthexec/enrich.go b/x-pack/heartbeat/monitors/browser/synthexec/enrich.go index eda6fbedba65..a0b6758644f1 100644 --- a/x-pack/heartbeat/monitors/browser/synthexec/enrich.go +++ b/x-pack/heartbeat/monitors/browser/synthexec/enrich.go @@ -102,6 +102,15 @@ func (je *journeyEnricher) enrich(event *beat.Event, se *SynthEvent) error { } func (je *journeyEnricher) enrichSynthEvent(event *beat.Event, se *SynthEvent) error { + var jobErr error + if se.Error != nil { + jobErr = stepError(se.Error) + je.errorCount++ + if je.firstError == nil { + je.firstError = jobErr + } + } + switch se.Type { case "journey/end": je.journeyComplete = true @@ -133,16 +142,6 @@ func (je *journeyEnricher) enrichSynthEvent(event *beat.Event, se *SynthEvent) e } } } - - var jobErr error - if se.Error != nil { - jobErr = stepError(se.Error) - je.errorCount++ - if je.firstError == nil { - je.firstError = jobErr - } - } - return jobErr }