Skip to content

Commit

Permalink
Marshal heartbeat duration as int64,string to prevent int64 -> float …
Browse files Browse the repository at this point in the history
…conversion (#34280)

* Add test initial state and build tag

* Keep int64 precision on marshal

* Add changelog
  • Loading branch information
emilioalvap authored Jan 26, 2023
1 parent 4c46e5d commit 762ad18
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
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.2.0\...main[Check the HEAD diff]
- Fix handling of long UDP messages in UDP input. {issue}33836[33836] {pull}33837[33837]
- Fix browser monitor summary reporting as up when monitor is down. {issue}33374[33374] {pull}33819[33819]
- Fix beat capabilities on Docker image. {pull}33584[33584]
- Fix serialization of state duration to avoid scientific notation. {pull}34280[34280]


*Heartbeat*
Expand Down
3 changes: 3 additions & 0 deletions heartbeat/monitors/wrappers/monitorstate/esloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// under the License.

//go:build integration
// +build integration

package monitorstate

Expand Down Expand Up @@ -126,6 +127,8 @@ func (etc *esTestContext) createTestMonitorStateInES(t *testing.T, s StateStatus
}

initState := newMonitorState(sf, s, 0, true)
// Test int64 is un/marshalled correctly
initState.DurationMs = 3e9
etc.setInitialState(t, sf, initState)
return sf
}
Expand Down
2 changes: 1 addition & 1 deletion heartbeat/monitors/wrappers/monitorstate/monitorstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type State struct {
ID string `json:"id"`
// StartedAt is the start time of the state, should be the same for a given state ID
StartedAt time.Time `json:"started_at"`
DurationMs int64 `json:"duration_ms"`
DurationMs int64 `json:"duration_ms,string"`
Status StateStatus `json:"status"`
Checks int `json:"checks"`
Up int `json:"up"`
Expand Down

0 comments on commit 762ad18

Please sign in to comment.