Skip to content

Commit

Permalink
fix: adjust formatting for heartbeat monitor and state loader (#37427)
Browse files Browse the repository at this point in the history
* fix: adjust formatting for heartbeat monitor and state loader

* reset ES error
  • Loading branch information
vigneshshanmugam authored Dec 13, 2023
1 parent ef1bce5 commit 6c5d221
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
*Heartbeat*

- Fix panics when parsing dereferencing invalid parsed url. {pull}34702[34702]
- Added fix for formatting the logs from stateloader properly. {pull}37369[37369]

*Metricbeat*

Expand Down
2 changes: 1 addition & 1 deletion heartbeat/monitors/active/icmp/stdloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (l *stdICMPLoop) runICMPRecv(conn *icmp.PacketConn, proto int) {
bytes := make([]byte, 512)
err := conn.SetReadDeadline(time.Now().Add(time.Second))
if err != nil {
logp.L().Error("could not set read deadline for ICMP: %w", err)
logp.L().Errorf("could not set read deadline for ICMP: %w", err)
return
}
_, addr, err := conn.ReadFrom(bytes)
Expand Down
2 changes: 1 addition & 1 deletion heartbeat/monitors/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func (m *Monitor) Stop() {
if m.close != nil {
err := m.close()
if err != nil {
logp.L().Error("error closing monitor %s: %w", m.String(), err)
logp.L().Errorf("error closing monitor %s: %w", m.String(), err)
}
}

Expand Down
6 changes: 3 additions & 3 deletions heartbeat/monitors/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ func (t *configuredJob) Start(pubClient beat.Client) {
t.pubClient = pubClient

if err != nil {
logp.L().Info("could not start monitor: %v", err)
logp.L().Infof("could not start monitor: %v", err)
return
}

t.cancelFn, err = t.monitor.addTask(t.config.Schedule, t.monitor.stdFields.ID, t.makeSchedulerTaskFunc(), t.config.Type)
if err != nil {
logp.L().Info("could not start monitor: %v", err)
logp.L().Infof("could not start monitor: %v", err)
}
}

Expand All @@ -107,7 +107,7 @@ func runPublishJob(job jobs.Job, pubClient beat.Client) []scheduler.TaskFunc {

conts, err := job(event)
if err != nil {
logp.L().Info("Job failed with: %s", err)
logp.L().Infof("Job failed with: %s", err)
}

hasContinuations := len(conts) > 0
Expand Down
2 changes: 1 addition & 1 deletion heartbeat/monitors/wrappers/monitorstate/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (t *Tracker) GetCurrentState(sf stdfields.StdMonitorFields) (state *State)
time.Sleep(sleepFor)
}
if err != nil {
logp.L().Warn("could not load prior state from elasticsearch after %d attempts, will create new state for monitor: %s", tries, sf.ID)
logp.L().Warnf("could not load prior state from elasticsearch after %d attempts, will create new state for monitor: %s", tries, sf.ID)
}

if loadedState != nil {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/heartbeat/monitors/browser/sourcejob.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (sj *SourceJob) extraArgs(uiOrigin bool) []string {
s, err := json.Marshal(sj.browserCfg.PlaywrightOpts)
if err != nil {
// This should never happen, if it was parsed as a config it should be serializable
logp.L().Warn("could not serialize playwright options '%v': %w", sj.browserCfg.PlaywrightOpts, err)
logp.L().Warnf("could not serialize playwright options '%v': %w", sj.browserCfg.PlaywrightOpts, err)
} else {
extraArgs = append(extraArgs, "--playwright-options", string(s))
}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/heartbeat/monitors/browser/synthexec/synthexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func runCmd(
break
}
if err != nil {
logp.L().Warn("error decoding json for test json results: %w", err)
logp.L().Warnf("error decoding json for test json results: %w", err)
}

mpx.writeSynthEvent(&se)
Expand Down
2 changes: 1 addition & 1 deletion x-pack/heartbeat/monitors/browser/synthexec/synthtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (se SynthEvent) ToMap() (m mapstr.M) {
u, e := url.Parse(se.URL)
if e != nil {
_, _ = m.Put("url", mapstr.M{"full": se.URL})
logp.L().Warn("Could not parse synthetics URL '%s': %s", se.URL, e.Error())
logp.L().Warnf("Could not parse synthetics URL '%s': %s", se.URL, e.Error())
} else {
_, _ = m.Put("url", wraputil.URLFields(u))
}
Expand Down

0 comments on commit 6c5d221

Please sign in to comment.