Fix ints being capped at 32-bits on 32-bit archs (#4054)
This commit is contained in:
parent
4df09fbd39
commit
493ec3773b
|
@ -282,7 +282,7 @@ var ptests = []struct {
|
||||||
"cpu",
|
"cpu",
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"value": 9223372036854775807,
|
"value": int64(9223372036854775807),
|
||||||
},
|
},
|
||||||
time.Unix(42, 0),
|
time.Unix(42, 0),
|
||||||
),
|
),
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
)
|
)
|
||||||
|
|
||||||
const MaxInt = int(^uint(0) >> 1)
|
const MaxInt64 = int64(^uint64(0) >> 1)
|
||||||
|
|
||||||
type FieldSortOrder int
|
type FieldSortOrder int
|
||||||
|
|
||||||
|
@ -270,10 +270,10 @@ func (s *Serializer) appendFieldValue(buf []byte, value interface{}) ([]byte, er
|
||||||
if s.fieldTypeSupport&UintSupport != 0 {
|
if s.fieldTypeSupport&UintSupport != 0 {
|
||||||
return appendUintField(buf, v), nil
|
return appendUintField(buf, v), nil
|
||||||
} else {
|
} else {
|
||||||
if v <= uint64(MaxInt) {
|
if v <= uint64(MaxInt64) {
|
||||||
return appendIntField(buf, int64(v)), nil
|
return appendIntField(buf, int64(v)), nil
|
||||||
} else {
|
} else {
|
||||||
return appendIntField(buf, int64(MaxInt)), nil
|
return appendIntField(buf, int64(MaxInt64)), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case int64:
|
case int64:
|
||||||
|
|
|
@ -129,6 +129,20 @@ var tests = []struct {
|
||||||
),
|
),
|
||||||
output: []byte("cpu value=42i 0\n"),
|
output: []byte("cpu value=42i 0\n"),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "integer field 64-bit",
|
||||||
|
input: MustMetric(
|
||||||
|
metric.New(
|
||||||
|
"cpu",
|
||||||
|
map[string]string{},
|
||||||
|
map[string]interface{}{
|
||||||
|
"value": int64(123456789012345),
|
||||||
|
},
|
||||||
|
time.Unix(0, 0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
output: []byte("cpu value=123456789012345i 0\n"),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "uint field",
|
name: "uint field",
|
||||||
input: MustMetric(
|
input: MustMetric(
|
||||||
|
|
Loading…
Reference in New Issue