Add influx uint support as a runtime option (#3948)
This commit is contained in:
@@ -16,12 +16,6 @@ func Metric(v telegraf.Metric, err error) telegraf.Metric {
|
||||
return v
|
||||
}
|
||||
|
||||
const (
|
||||
Uint64Overflow uint64 = 9223372036854775808
|
||||
Uint64Max uint64 = 18446744073709551615
|
||||
Uint64Test uint64 = 42
|
||||
)
|
||||
|
||||
var DefaultTime = func() time.Time {
|
||||
return time.Unix(42, 0)
|
||||
}
|
||||
@@ -262,6 +256,38 @@ var ptests = []struct {
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "field int overflow dropped",
|
||||
input: []byte("cpu value=9223372036854775808i"),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "field int max value",
|
||||
input: []byte("cpu value=9223372036854775807i"),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
"value": 9223372036854775807,
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "field uint",
|
||||
input: []byte("cpu value=42u"),
|
||||
@@ -271,7 +297,7 @@ var ptests = []struct {
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
"value": Uint64Test,
|
||||
"value": uint64(42),
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
@@ -280,16 +306,14 @@ var ptests = []struct {
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "field uint int overflow",
|
||||
input: []byte("cpu value=9223372036854775808u"),
|
||||
name: "field uint overflow dropped",
|
||||
input: []byte("cpu value=18446744073709551616u"),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
"value": Uint64Overflow,
|
||||
},
|
||||
map[string]interface{}{},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
@@ -297,7 +321,7 @@ var ptests = []struct {
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "field uint maximum",
|
||||
name: "field uint max value",
|
||||
input: []byte("cpu value=18446744073709551615u"),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
@@ -305,7 +329,7 @@ var ptests = []struct {
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
"value": Uint64Max,
|
||||
"value": uint64(18446744073709551615),
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user