Skip to content

Commit

Permalink
Merge pull request #6 from cloudflare/dont_output_error
Browse files Browse the repository at this point in the history
Don't output error in HTTP response body
  • Loading branch information
mattbostock committed Jul 5, 2017
2 parents 7ba7191 + 9f90fed commit b5981ae
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.go
Expand Up @@ -2,6 +2,7 @@ package main

import (
"encoding/json"
"errors"
"flag"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -90,14 +91,14 @@ func (c *collector) Collect(ch chan<- prometheus.Metric) {
metrics, err := c.queryOpenTSDB()
if err != nil {
log.Errorf("Error scraping target %s: %s", c.target, err)
ch <- prometheus.NewInvalidMetric(prometheus.NewDesc("api_error", "Error scraping target", nil, nil), err)
ch <- prometheus.NewInvalidMetric(prometheus.NewDesc("api_error", "", nil, nil), errors.New("Error scraping target, check exporter logs"))
return
}
for _, m := range *metrics {
value, err := m.Value.Float64()
if err != nil {
log.Errorf("Error scraping target %s: %s", c.target, err)
ch <- prometheus.NewInvalidMetric(prometheus.NewDesc("api_error", "Error scraping target", nil, nil), err)
ch <- prometheus.NewInvalidMetric(prometheus.NewDesc("api_error", "", nil, nil), errors.New("Error scraping target, check exporter logs"))
return
}

Expand Down

0 comments on commit b5981ae

Please sign in to comment.