Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marshal heartbeat duration as int64,string to prevent int64 -> float conversion #34280

Merged
merged 3 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"`
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this modifier seems easier than changing the struct to a map representation

Status StateStatus `json:"status"`
Checks int `json:"checks"`
Up int `json:"up"`
Expand Down