Compare commits

...

1 Commits

Author SHA1 Message Date
Daniel Nelson 1989287606
Use %q format when printing influxdb errors 2018-06-05 17:25:09 -07:00
1 changed files with 10 additions and 10 deletions

View File

@ -140,17 +140,17 @@ func (i *InfluxDB) Connect() error {
i.serializer.SetFieldTypeSupport(influx.UintSupport) i.serializer.SetFieldTypeSupport(influx.UintSupport)
} }
for _, u := range urls { for _, loc := range urls {
u, err := url.Parse(u) u, err := url.Parse(loc)
if err != nil { if err != nil {
return fmt.Errorf("error parsing url [%s]: %v", u, err) return fmt.Errorf("error parsing url [%q]: %v", loc, err)
} }
var proxy *url.URL var proxy *url.URL
if len(i.HTTPProxy) > 0 { if len(i.HTTPProxy) > 0 {
proxy, err = url.Parse(i.HTTPProxy) proxy, err = url.Parse(i.HTTPProxy)
if err != nil { if err != nil {
return fmt.Errorf("error parsing proxy_url [%s]: %v", proxy, err) return fmt.Errorf("error parsing proxy_url [%q]: %v", proxy, err)
} }
} }
@ -170,7 +170,7 @@ func (i *InfluxDB) Connect() error {
i.clients = append(i.clients, c) i.clients = append(i.clients, c)
default: default:
return fmt.Errorf("unsupported scheme [%s]: %q", u, u.Scheme) return fmt.Errorf("unsupported scheme [%q]: %q", u, u.Scheme)
} }
} }
@ -209,14 +209,14 @@ func (i *InfluxDB) Write(metrics []telegraf.Metric) error {
if apiError.Type == DatabaseNotFound { if apiError.Type == DatabaseNotFound {
err := client.CreateDatabase(ctx) err := client.CreateDatabase(ctx)
if err != nil { if err != nil {
log.Printf("E! [outputs.influxdb] when writing to [%s]: database %q not found and failed to recreate", log.Printf("E! [outputs.influxdb] when writing to [%q]: database %q not found and failed to recreate",
client.URL(), client.Database()) client.URL(), client.Database())
} }
} }
} }
} }
log.Printf("E! [outputs.influxdb]: when writing to [%s]: %v", client.URL(), err) log.Printf("E! [outputs.influxdb]: when writing to [%q]: %v", client.URL(), err)
} }
return errors.New("could not write any address") return errors.New("could not write any address")
@ -231,7 +231,7 @@ func (i *InfluxDB) udpClient(url *url.URL) (Client, error) {
c, err := i.CreateUDPClientF(config) c, err := i.CreateUDPClientF(config)
if err != nil { if err != nil {
return nil, fmt.Errorf("error creating UDP client [%s]: %v", url, err) return nil, fmt.Errorf("error creating UDP client [%q]: %v", url, err)
} }
return c, nil return c, nil
@ -261,13 +261,13 @@ func (i *InfluxDB) httpClient(ctx context.Context, url *url.URL, proxy *url.URL)
c, err := i.CreateHTTPClientF(config) c, err := i.CreateHTTPClientF(config)
if err != nil { if err != nil {
return nil, fmt.Errorf("error creating HTTP client [%s]: %v", url, err) return nil, fmt.Errorf("error creating HTTP client [%q]: %v", url, err)
} }
if !i.SkipDatabaseCreation { if !i.SkipDatabaseCreation {
err = c.CreateDatabase(ctx) err = c.CreateDatabase(ctx)
if err != nil { if err != nil {
log.Printf("W! [outputs.influxdb] when writing to [%s]: database %q creation failed: %v", log.Printf("W! [outputs.influxdb] when writing to [%q]: database %q creation failed: %v",
c.URL(), c.Database(), err) c.URL(), c.Database(), err)
} }
} }