CloudWatch/Logs: Fix missing response data for log queries (#35724)

pull/35760/head
Andrej Ocenas 4 years ago committed by GitHub
parent b774dd9b1a
commit 9a3e3014dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      pkg/tsdb/cloudwatch/live.go
  2. 10
      pkg/tsdb/cloudwatch/logs.go

@ -18,7 +18,6 @@ import (
"github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util/retryer"
"golang.org/x/sync/errgroup"
@ -111,7 +110,7 @@ func (r *logQueryRunner) publishResults(orgID int64, channelName string) error {
//nolint: staticcheck // plugins.DataResponse deprecated
func (e *cloudWatchExecutor) executeLiveLogQuery(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
responseChannelName := uuid.New().String()
responseChannel := make(chan plugins.DataResponse)
responseChannel := make(chan *backend.QueryDataResponse)
if err := e.logsService.AddResponseChannel("plugin/cloudwatch/"+responseChannelName, responseChannel); err != nil {
close(responseChannel)
return nil, err
@ -135,7 +134,7 @@ func (e *cloudWatchExecutor) executeLiveLogQuery(ctx context.Context, req *backe
}
//nolint: staticcheck // plugins.DataResponse deprecated
func (e *cloudWatchExecutor) sendLiveQueriesToChannel(req *backend.QueryDataRequest, responseChannel chan plugins.DataResponse) {
func (e *cloudWatchExecutor) sendLiveQueriesToChannel(req *backend.QueryDataRequest, responseChannel chan *backend.QueryDataResponse) {
defer close(responseChannel)
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Minute)
@ -213,7 +212,7 @@ func (e *cloudWatchExecutor) fetchConcurrentQueriesQuota(region string, pluginCt
}
//nolint: staticcheck // plugins.DataResponse deprecated
func (e *cloudWatchExecutor) startLiveQuery(ctx context.Context, responseChannel chan plugins.DataResponse, query backend.DataQuery, timeRange backend.TimeRange, pluginCtx backend.PluginContext) error {
func (e *cloudWatchExecutor) startLiveQuery(ctx context.Context, responseChannel chan *backend.QueryDataResponse, query backend.DataQuery, timeRange backend.TimeRange, pluginCtx backend.PluginContext) error {
model, err := simplejson.NewJson(query.JSON)
if err != nil {
return err
@ -295,11 +294,10 @@ func (e *cloudWatchExecutor) startLiveQuery(ctx context.Context, responseChannel
dataFrames = data.Frames{dataFrame}
}
responseChannel <- plugins.DataResponse{
Results: map[string]plugins.DataQueryResult{
responseChannel <- &backend.QueryDataResponse{
Responses: backend.Responses{
query.RefID: {
RefID: query.RefID,
Dataframes: plugins.NewDecodedDataFrames(dataFrames),
Frames: dataFrames,
},
},
}

@ -4,7 +4,7 @@ import (
"fmt"
"sync"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana/pkg/registry"
)
@ -16,7 +16,7 @@ func init() {
type LogsService struct {
channelMu sync.Mutex
// nolint:staticcheck // plugins.DataQueryResult deprecated
responseChannels map[string]chan plugins.DataResponse
responseChannels map[string]chan *backend.QueryDataResponse
queues map[string](chan bool)
queueLock sync.Mutex
}
@ -24,13 +24,13 @@ type LogsService struct {
// Init is called by the DI framework to initialize the instance.
func (s *LogsService) Init() error {
// nolint:staticcheck // plugins.DataQueryResult deprecated
s.responseChannels = make(map[string]chan plugins.DataResponse)
s.responseChannels = make(map[string]chan *backend.QueryDataResponse)
s.queues = make(map[string](chan bool))
return nil
}
// nolint:staticcheck // plugins.DataQueryResult deprecated
func (s *LogsService) AddResponseChannel(name string, channel chan plugins.DataResponse) error {
func (s *LogsService) AddResponseChannel(name string, channel chan *backend.QueryDataResponse) error {
s.channelMu.Lock()
defer s.channelMu.Unlock()
@ -43,7 +43,7 @@ func (s *LogsService) AddResponseChannel(name string, channel chan plugins.DataR
}
// nolint:staticcheck // plugins.DataQueryResult deprecated
func (s *LogsService) GetResponseChannel(name string) (chan plugins.DataResponse, error) {
func (s *LogsService) GetResponseChannel(name string) (chan *backend.QueryDataResponse, error) {
s.channelMu.Lock()
defer s.channelMu.Unlock()

Loading…
Cancel
Save