CloudWatch: Add errorsource for QueryData (#91085)
This commit is contained in:
@@ -3,6 +3,7 @@ package cloudwatch
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
@@ -10,6 +11,7 @@ import (
|
||||
"github.com/aws/aws-sdk-go/service/cloudwatchlogs/cloudwatchlogsiface"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/experimental/errorsource"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/kinds/dataquery"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/utils"
|
||||
@@ -47,7 +49,17 @@ var executeSyncLogQuery = func(ctx context.Context, e *cloudWatchExecutor, req *
|
||||
return nil, err
|
||||
}
|
||||
|
||||
refId := "A"
|
||||
if q.RefID != "" {
|
||||
refId = q.RefID
|
||||
}
|
||||
|
||||
getQueryResultsOutput, err := e.syncQuery(ctx, logsClient, q, logsQuery, instance.Settings.LogsTimeout.Duration)
|
||||
var sourceError errorsource.Error
|
||||
if errors.As(err, &sourceError) {
|
||||
errorsource.AddErrorToResponse(refId, resp, sourceError)
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -67,11 +79,6 @@ var executeSyncLogQuery = func(ctx context.Context, e *cloudWatchExecutor, req *
|
||||
frames = data.Frames{dataframe}
|
||||
}
|
||||
|
||||
refId := "A"
|
||||
if q.RefID != "" {
|
||||
refId = q.RefID
|
||||
}
|
||||
|
||||
respD := resp.Responses[refId]
|
||||
respD.Frames = frames
|
||||
resp.Responses[refId] = respD
|
||||
@@ -109,7 +116,7 @@ func (e *cloudWatchExecutor) syncQuery(ctx context.Context, logsClient cloudwatc
|
||||
for range ticker.C {
|
||||
res, err := e.executeGetQueryResults(ctx, logsClient, requestParams)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("CloudWatch Error: %w", err)
|
||||
return nil, err
|
||||
}
|
||||
if isTerminated(*res.Status) {
|
||||
return res, err
|
||||
|
||||
Reference in New Issue
Block a user