Skip non-numerical values in graphite format (#3179)

This commit is contained in:
Seua Polyakov
2017-08-30 01:59:38 +03:00
committed by Daniel Nelson
parent ef8876b70b
commit 3806424aab
3 changed files with 32 additions and 5 deletions

View File

@@ -165,6 +165,28 @@ func TestSerializeValueField2(t *testing.T) {
assert.Equal(t, expS, mS)
}
func TestSerializeValueString(t *testing.T) {
now := time.Now()
tags := map[string]string{
"host": "localhost",
"cpu": "cpu0",
"datacenter": "us-west-2",
}
fields := map[string]interface{}{
"value": "asdasd",
}
m, err := metric.New("cpu", tags, fields, now)
assert.NoError(t, err)
s := GraphiteSerializer{
Template: "host.field.tags.measurement",
}
buf, _ := s.Serialize(m)
mS := strings.Split(strings.TrimSpace(string(buf)), "\n")
assert.NoError(t, err)
assert.Equal(t, "", mS[0])
}
// test that fields with spaces get fixed.
func TestSerializeFieldWithSpaces(t *testing.T) {
now := time.Now()