Enable strings as field values in stdout sink

This commit is contained in:
Thomas Roehl 2021-05-12 17:46:16 +02:00
parent e8b2bbdae1
commit b84dc08cd6

View File

@ -27,8 +27,13 @@ func (s *StdoutSink) Write(measurement string, tags map[string]string, fields ma
tagsstr = append(tagsstr, fmt.Sprintf("%s=%s", k, v)) tagsstr = append(tagsstr, fmt.Sprintf("%s=%s", k, v))
} }
for k, v := range fields { for k, v := range fields {
if !math.IsNaN(v.(float64)) { switch v.(type) {
fieldstr = append(fieldstr, fmt.Sprintf("%s=%v", k, v.(float64))) case float64:
if !math.IsNaN(v.(float64)) {
fieldstr = append(fieldstr, fmt.Sprintf("%s=%v", k, v.(float64)))
}
case string:
fieldstr = append(fieldstr, fmt.Sprintf("%s=%q", k, v.(string)))
} }
} }
if len(tagsstr) > 0 { if len(tagsstr) > 0 {