mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
tech(graphite): add more logging
This commit is contained in:
@@ -13,6 +13,10 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/tsdb"
|
"github.com/grafana/grafana/pkg/tsdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
HttpClient = http.Client{Timeout: time.Duration(10 * time.Second)}
|
||||||
|
)
|
||||||
|
|
||||||
type GraphiteExecutor struct {
|
type GraphiteExecutor struct {
|
||||||
*tsdb.DataSourceInfo
|
*tsdb.DataSourceInfo
|
||||||
}
|
}
|
||||||
@@ -43,20 +47,27 @@ func (e *GraphiteExecutor) Execute(queries tsdb.QuerySlice, context *tsdb.QueryC
|
|||||||
glog.Debug("Graphite request", "query", query.Query)
|
glog.Debug("Graphite request", "query", query.Query)
|
||||||
}
|
}
|
||||||
|
|
||||||
client := http.Client{Timeout: time.Duration(10 * time.Second)}
|
formData := params.Encode()
|
||||||
req, _ := http.NewRequest(http.MethodPost, e.Url+"/render?", strings.NewReader(params.Encode()))
|
glog.Info("Graphite request body", "formdata", formData)
|
||||||
|
req, err := http.NewRequest(http.MethodPost, e.Url+"/render", strings.NewReader(formData))
|
||||||
|
if err != nil {
|
||||||
|
glog.Info("Failed to create request", "error", err)
|
||||||
|
result.Error = fmt.Errorf("Failed to create request. error: %v", err)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
if e.BasicAuth {
|
if e.BasicAuth {
|
||||||
req.SetBasicAuth(e.BasicAuthUser, e.BasicAuthPassword)
|
req.SetBasicAuth(e.BasicAuthUser, e.BasicAuthPassword)
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := client.Do(req)
|
res, err := HttpClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
result.Error = err
|
result.Error = err
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
defer res.Body.Close()
|
|
||||||
body, err := ioutil.ReadAll(res.Body)
|
body, err := ioutil.ReadAll(res.Body)
|
||||||
|
defer res.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
result.Error = err
|
result.Error = err
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user