Skip to content

Commit

Permalink
Remove common.Float (elastic#28376)
Browse files Browse the repository at this point in the history
Remove deprecated common.Float from 8.0.

Relates elastic#28279
Relates elastic#28280
  • Loading branch information
andrewkroh authored and wiwen committed Nov 1, 2021
1 parent fc05b81 commit e45cf08
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 36 deletions.
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 @@ -124,7 +125,3 @@ The list below covers the major changes between 7.0.0-rc2 and master only.
-- The `enable_idempotent` config is a boolean setting to enable or disable the output support Idempotent. {pull}28095[28095]
- 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

0 comments on commit e45cf08

Please sign in to comment.