Support floats in statsd percentiles (#5572)

This commit is contained in:
Pitxyoki
2019-07-10 00:50:20 +01:00
committed by Daniel Nelson
parent 70e2ccce75
commit 72c2ac9648
6 changed files with 45 additions and 15 deletions

View File

@@ -48,6 +48,10 @@ type Size struct {
Size int64
}
type Number struct {
Value float64
}
// SetVersion sets the telegraf agent version
func SetVersion(v string) error {
if version != "" {
@@ -124,6 +128,16 @@ func (s *Size) UnmarshalTOML(b []byte) error {
return nil
}
func (n *Number) UnmarshalTOML(b []byte) error {
value, err := strconv.ParseFloat(string(b), 64)
if err != nil {
return err
}
n.Value = value
return nil
}
// ReadLines reads contents from a file and splits them by new lines.
// A convenience wrapper to ReadLinesOffsetN(filename, 0, -1).
func ReadLines(filename string) ([]string, error) {