Skip to content

Commit

Permalink
[Heartbeat]: fix status field when monitors are down
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshshanmugam committed Sep 19, 2023
1 parent ccfa54a commit 2e68b6d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ func NewJobSummary(attempt uint16, maxAttempts uint16, retryGroup string) *JobSu
// BumpAttempt swaps the JobSummary object's pointer for a new job summary
// that is a clone of the current one but with the Attempt field incremented.
func (js *JobSummary) BumpAttempt() {
*js = *NewJobSummary(js.Attempt+1, js.MaxAttempts, js.RetryGroup)
newJs := *NewJobSummary(js.Attempt+1, js.MaxAttempts, js.RetryGroup)
newJs.Up = js.Up
newJs.Down = js.Down
newJs.Status = js.Status
*js = newJs
}

func (js *JobSummary) String() string {
Expand Down
12 changes: 4 additions & 8 deletions heartbeat/monitors/wrappers/summarizer/plugstatestat.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func (ssp *BrowserStateStatusPlugin) BeforeSummary(event *beat.Event) BeforeSumm
res := ssp.cssp.BeforeSummary(event)

_, _ = event.PutValue("monitor.status", string(ssp.cssp.js.Status))
_, _ = event.PutValue("synthetics", mapstr.M{"type": "heartbeat/summary"})
return res
}

Expand Down Expand Up @@ -162,19 +163,14 @@ func (ssp *commonSSP) BeforeSummary(event *beat.Event) BeforeSummaryActions {
"summary": &jsCopy,
"state": ms,
}
if ssp.sf.Type == "browser" {
fields["synthetics"] = mapstr.M{"type": "heartbeat/summary"}
}

eventext.MergeEventFields(event, fields)

logp.L().Debugf("attempt info: current(%v) == lastStatus(%v) && attempts(%d < %d)", ssp.js.Status, lastStatus, ssp.js.Attempt, ssp.js.MaxAttempts)

if retry {
// mutate the js into the state for the next attempt
ssp.js.BumpAttempt()
}

logp.L().Debugf("attempt info: %v == %v && %d < %d", ssp.js.Status, lastStatus, ssp.js.Attempt, ssp.js.MaxAttempts)

if retry {
return RetryBeforeSummary
}

Expand Down

0 comments on commit 2e68b6d

Please sign in to comment.