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

[libbeat] Remove common.Float #28376

Merged
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
5 changes: 1 addition & 4 deletions CHANGELOG-developer.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ The list below covers the major changes between 7.0.0-rc2 and master only.
- Remove `NumCPU` as clients should update the CPU count on the fly in case of config changes in a VM. {pull}23154[23154]
- Remove Metricbeat EventFetcher and EventsFetcher interface. Use the reporter interface instead. {pull}25093[25093]
- Update Darwin build image to a debian 10 base that increases the MacOS SDK and minimum supported version used in build to 10.14. {issue}24193[24193]
- Removed the `common.Float` type. {issue}28279[28279] {pull}28280[28280] {pull}28376[28376]

==== Bugfixes

Expand Down Expand Up @@ -123,7 +124,3 @@ The list below covers the major changes between 7.0.0-rc2 and master only.
- Update Go version to 1.16.5. {issue}26182[26182] {pull}26186[26186]
- Introduce `libbeat/beat.Beat.OutputConfigReloader` {pull}28048[28048]
- Update Go version to 1.17.1. {pull}27543[27543]

==== Deprecated

- Deprecated the `common.Float` type. {issue}28279[28279] {pull}28280[28280]
14 changes: 0 additions & 14 deletions libbeat/common/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ import (
"github.com/elastic/beats/v7/libbeat/logp"
)

var textMarshalerType = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem()

// Float is a float64 wrapper that implements the encoding/json Marshaler
// interface to add a decimal point to all float values.
//
// Deprecated: This type should no longer be used and the Marshaler interface
// is not consulted while marshaling to JSON in libbeat outputs.
type Float float64

// EventConverter is used to convert MapStr objects for publishing
type EventConverter interface {
Convert(m MapStr) MapStr
Expand Down Expand Up @@ -306,11 +297,6 @@ func joinKeys(keys ...string) string {
return strings.Join(keys, ".")
}

// Defines the marshal of the Float type
func (f Float) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf("%.6f", f)), nil
}

// DeDot a string by replacing all . with _
// This helps when sending data to Elasticsearch to prevent object and key collisions.
func DeDot(s string) string {
Expand Down
16 changes: 0 additions & 16 deletions libbeat/common/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,22 +396,6 @@ func TestMarshalUnmarshalArray(t *testing.T) {
}
}

func TestMarshalFloatValues(t *testing.T) {
assert := assert.New(t)

var f float64

f = 5

a := MapStr{
"f": Float(f),
}

b, err := json.Marshal(a)
assert.Nil(err)
assert.Equal(string(b), "{\"f\":5.000000}")
}

func TestNormalizeTime(t *testing.T) {
ny, err := time.LoadLocation("America/New_York")
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions libbeat/conditions/range.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"reflect"
"strings"

"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/logp"
)

Expand Down Expand Up @@ -129,7 +128,7 @@ func (c Range) Check(event ValuesMap) bool {
return false
}

case float64, float32, common.Float:
case float64, float32:
floatValue := reflect.ValueOf(value).Float()

if !checkValue(floatValue, rangeValue) {
Expand Down