Skip to content

Commit

Permalink
just in case, add debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
arkady-emelyanov committed Nov 23, 2017
1 parent 9636c16 commit c28689e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions plugins/inputs/burrow/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package burrow
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"log"
"net/http"

"fmt"
"github.com/influxdata/telegraf"
)

Expand Down Expand Up @@ -115,11 +117,17 @@ func (api *apiClient) call(uri string) (apiResponse, error) {

// decode response
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
return br, err
}

log.Printf("D! call: %s, code: %d, body: %s\n", req.URL.String(), res.StatusCode, string(body))
if res.StatusCode != http.StatusOK {
return br, fmt.Errorf("endpoint: '%s', invalid response code: '%d'", uri, res.StatusCode)
}

if err := json.NewDecoder(res.Body).Decode(&br); err != nil {
if err := json.Unmarshal(body, &br); err != nil {
return br, err
}

Expand Down

0 comments on commit c28689e

Please sign in to comment.