Only log warning on type when in debug mode.

closes #1793
This commit is contained in:
Eric 2016-09-21 10:29:22 -04:00 committed by Cameron Sparr
parent 1f7a8fceef
commit 3e3b094270
2 changed files with 4 additions and 5 deletions

View File

@ -57,6 +57,7 @@ continue sending logs to /var/log/telegraf/telegraf.log.
- [#1835](https://github.com/influxdata/telegraf/issues/1835): Fix SNMP emitting empty fields. - [#1835](https://github.com/influxdata/telegraf/issues/1835): Fix SNMP emitting empty fields.
- [#1854](https://github.com/influxdata/telegraf/pull/1853): SQL Server waitstats truncation bug. - [#1854](https://github.com/influxdata/telegraf/pull/1853): SQL Server waitstats truncation bug.
- [#1810](https://github.com/influxdata/telegraf/issues/1810): Fix logparser common log format: numbers in ident. - [#1810](https://github.com/influxdata/telegraf/issues/1810): Fix logparser common log format: numbers in ident.
- [#1793](https://github.com/influxdata/telegraf/pull/1793): Fix JSON Serialization in OpenTSDB output.
## v1.0.1 [2016-09-26] ## v1.0.1 [2016-09-26]

View File

@ -2,6 +2,7 @@ package opentsdb
import ( import (
"fmt" "fmt"
"log"
"net" "net"
"net/url" "net/url"
"sort" "sort"
@ -114,7 +115,7 @@ func (o *OpenTSDB) WriteHttp(metrics []telegraf.Metric, u *url.URL) error {
case uint64: case uint64:
case float64: case float64:
default: default:
fmt.Printf("OpenTSDB does not support metric value: [%s] of type [%T].\n", value, value) log.Printf("D! OpenTSDB does not support metric value: [%s] of type [%T].\n", value, value)
continue continue
} }
@ -156,7 +157,7 @@ func (o *OpenTSDB) WriteTelnet(metrics []telegraf.Metric, u *url.URL) error {
for fieldName, value := range m.Fields() { for fieldName, value := range m.Fields() {
metricValue, buildError := buildValue(value) metricValue, buildError := buildValue(value)
if buildError != nil { if buildError != nil {
fmt.Printf("OpenTSDB: %s\n", buildError.Error()) log.Printf("E! OpenTSDB: %s\n", buildError.Error())
continue continue
} }
@ -164,9 +165,6 @@ func (o *OpenTSDB) WriteTelnet(metrics []telegraf.Metric, u *url.URL) error {
sanitizedChars.Replace(fmt.Sprintf("%s%s_%s", o.Prefix, m.Name(), fieldName)), sanitizedChars.Replace(fmt.Sprintf("%s%s_%s", o.Prefix, m.Name(), fieldName)),
now, metricValue, tags) now, metricValue, tags)
if o.Debug {
fmt.Print(messageLine)
}
_, err := connection.Write([]byte(messageLine)) _, err := connection.Write([]byte(messageLine))
if err != nil { if err != nil {
return fmt.Errorf("OpenTSDB: Telnet writing error %s", err.Error()) return fmt.Errorf("OpenTSDB: Telnet writing error %s", err.Error())