Improve error handling in prometheus output (#5512)

This commit is contained in:
Greg 2019-03-01 14:26:11 -07:00 committed by Daniel Nelson
parent 9bd48d4673
commit 30fcaf0987
1 changed files with 5 additions and 1 deletions

View File

@ -176,7 +176,10 @@ func (p *PrometheusClient) Connect() error {
} }
} }
registry.Register(p) err := registry.Register(p)
if err != nil {
return err
}
if p.Listen == "" { if p.Listen == "" {
p.Listen = "localhost:9273" p.Listen = "localhost:9273"
@ -301,6 +304,7 @@ func (p *PrometheusClient) Collect(ch chan<- prometheus.Metric) {
log.Printf("E! Error creating prometheus metric, "+ log.Printf("E! Error creating prometheus metric, "+
"key: %s, labels: %v,\nerr: %s\n", "key: %s, labels: %v,\nerr: %s\n",
name, labels, err.Error()) name, labels, err.Error())
continue
} }
if p.ExportTimestamp { if p.ExportTimestamp {