mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
CloudWatch/Logs: Fix missing response data for log queries (#35724)
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user