Add line protocol uint64 support (#3946)

This commit is contained in:
Matt
2018-03-28 19:43:25 -04:00
committed by Daniel Nelson
parent ef112e6ee7
commit a320f91516
12 changed files with 8046 additions and 6754 deletions

View File

@@ -11,6 +11,16 @@ import (
const MaxInt = int(^uint(0) >> 1)
// enableUint64Support will enable uint64 support if set to true.
var enableUint64Support = false
// EnableUintSupport manually enables uint support for convertValue.
// This function will be removed in the future and only exists for unit tests during the
// transition.
func EnableUintSupport() {
enableUint64Support = true
}
type metric struct {
name string
tags []*telegraf.Tag
@@ -265,11 +275,14 @@ func convertField(v interface{}) interface{} {
return int64(MaxInt)
}
case uint64:
if v <= uint64(MaxInt) {
return int64(v)
} else {
return int64(MaxInt)
if enableUint64Support == false {
if v <= uint64(MaxInt) {
return int64(v)
} else {
return int64(MaxInt)
}
}
return uint64(v)
case []byte:
return string(v)
case int32:

7
metric/uint_support.go Normal file
View File

@@ -0,0 +1,7 @@
// +build uint64
package metric
func init() {
EnableUintSupport()
}