mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
stackdriver: type rename
This commit is contained in:
parent
3ba0195330
commit
669a1029ed
@ -203,29 +203,29 @@ func (e *StackdriverExecutor) executeQuery(ctx context.Context, query *Stackdriv
|
||||
return queryResult, nil
|
||||
}
|
||||
|
||||
func (e *StackdriverExecutor) unmarshalResponse(res *http.Response) (StackDriverResponse, error) {
|
||||
func (e *StackdriverExecutor) unmarshalResponse(res *http.Response) (StackdriverResponse, error) {
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
defer res.Body.Close()
|
||||
if err != nil {
|
||||
return StackDriverResponse{}, err
|
||||
return StackdriverResponse{}, err
|
||||
}
|
||||
|
||||
if res.StatusCode/100 != 2 {
|
||||
slog.Error("Request failed", "status", res.Status, "body", string(body))
|
||||
return StackDriverResponse{}, fmt.Errorf(string(body))
|
||||
return StackdriverResponse{}, fmt.Errorf(string(body))
|
||||
}
|
||||
|
||||
var data StackDriverResponse
|
||||
var data StackdriverResponse
|
||||
err = json.Unmarshal(body, &data)
|
||||
if err != nil {
|
||||
slog.Error("Failed to unmarshal Stackdriver response", "error", err, "status", res.Status, "body", string(body))
|
||||
return StackDriverResponse{}, err
|
||||
return StackdriverResponse{}, err
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (e *StackdriverExecutor) parseResponse(queryRes *tsdb.QueryResult, data StackDriverResponse) error {
|
||||
func (e *StackdriverExecutor) parseResponse(queryRes *tsdb.QueryResult, data StackdriverResponse) error {
|
||||
metricLabels := make(map[string][]string)
|
||||
resourceLabels := make(map[string][]string)
|
||||
|
||||
|
@ -117,7 +117,7 @@ func TestStackdriver(t *testing.T) {
|
||||
|
||||
Convey("Parse stackdriver response in the time series format", func() {
|
||||
Convey("when data from query aggregated to one time series", func() {
|
||||
var data StackDriverResponse
|
||||
var data StackdriverResponse
|
||||
|
||||
jsonBody, err := ioutil.ReadFile("./test-data/1-series-response-agg-one-metric.json")
|
||||
So(err, ShouldBeNil)
|
||||
@ -146,7 +146,7 @@ func TestStackdriver(t *testing.T) {
|
||||
})
|
||||
|
||||
Convey("when data from query with no aggregation", func() {
|
||||
var data StackDriverResponse
|
||||
var data StackdriverResponse
|
||||
|
||||
jsonBody, err := ioutil.ReadFile("./test-data/2-series-response-no-agg.json")
|
||||
So(err, ShouldBeNil)
|
||||
|
@ -11,7 +11,7 @@ type StackdriverQuery struct {
|
||||
RefID string
|
||||
}
|
||||
|
||||
type StackDriverResponse struct {
|
||||
type StackdriverResponse struct {
|
||||
TimeSeries []struct {
|
||||
Metric struct {
|
||||
Labels map[string]string `json:"labels"`
|
||||
|
Loading…
Reference in New Issue
Block a user