Commit 9c7022be by Erik Sundell

stackdriver: add status code

parent 412a1f6d
...@@ -22,7 +22,7 @@ func (e *StackdriverExecutor) executeMetricDescriptors(ctx context.Context, tsdb ...@@ -22,7 +22,7 @@ func (e *StackdriverExecutor) executeMetricDescriptors(ctx context.Context, tsdb
Results: make(map[string]*tsdb.QueryResult), Results: make(map[string]*tsdb.QueryResult),
} }
req, err := e.createRequest(ctx, e.dsInfo, "metricDescriptors") req, err := e.createRequest(ctx, e.dsInfo, "metricDescriptorss")
if err != nil { if err != nil {
slog.Error("Failed to create request", "error", err) slog.Error("Failed to create request", "error", err)
return nil, fmt.Errorf("Failed to create request. error: %v", err) return nil, fmt.Errorf("Failed to create request. error: %v", err)
...@@ -35,7 +35,11 @@ func (e *StackdriverExecutor) executeMetricDescriptors(ctx context.Context, tsdb ...@@ -35,7 +35,11 @@ func (e *StackdriverExecutor) executeMetricDescriptors(ctx context.Context, tsdb
data, err := e.unmarshalMetricDescriptors(res) data, err := e.unmarshalMetricDescriptors(res)
if err != nil { if err != nil {
return nil, err queryResult.ErrorString = fmt.Sprintf(`Status code: %d`, res.StatusCode)
logger.Info("error2", "ErrorString", queryResult.ErrorString)
queryResult.Error = err
result.Results[tsdbQuery.Queries[0].RefId] = queryResult
return result, nil
} }
parts := strings.Split(req.URL.Path, "/") parts := strings.Split(req.URL.Path, "/")
...@@ -73,7 +77,7 @@ func (e *StackdriverExecutor) unmarshalMetricDescriptors(res *http.Response) (Me ...@@ -73,7 +77,7 @@ func (e *StackdriverExecutor) unmarshalMetricDescriptors(res *http.Response) (Me
if res.StatusCode/100 != 2 { if res.StatusCode/100 != 2 {
slog.Error("Request failed", "status", res.Status, "body", string(body)) slog.Error("Request failed", "status", res.Status, "body", string(body))
return MetricDescriptorsResponse{}, fmt.Errorf(string(body)) return MetricDescriptorsResponse{}, fmt.Errorf(`Status code: %d - %s`, res.StatusCode, string(body))
} }
var data MetricDescriptorsResponse var data MetricDescriptorsResponse
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment