mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Remove data comparison tool and feature flag (#58196)
This commit is contained in:
parent
76947b10e2
commit
93c1fbbe3f
@ -53,7 +53,6 @@ export interface FeatureToggles {
|
|||||||
datasourceQueryMultiStatus?: boolean;
|
datasourceQueryMultiStatus?: boolean;
|
||||||
traceToMetrics?: boolean;
|
traceToMetrics?: boolean;
|
||||||
prometheusStreamingJSONParser?: boolean;
|
prometheusStreamingJSONParser?: boolean;
|
||||||
prometheusStreamingJSONParserTest?: boolean;
|
|
||||||
newDBLibrary?: boolean;
|
newDBLibrary?: boolean;
|
||||||
validateDashboardsOnSave?: boolean;
|
validateDashboardsOnSave?: boolean;
|
||||||
autoMigrateGraphPanels?: boolean;
|
autoMigrateGraphPanels?: boolean;
|
||||||
|
@ -212,11 +212,6 @@ var (
|
|||||||
Description: "Enable streaming JSON parser for Prometheus datasource",
|
Description: "Enable streaming JSON parser for Prometheus datasource",
|
||||||
State: FeatureStateBeta,
|
State: FeatureStateBeta,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Name: "prometheusStreamingJSONParserTest",
|
|
||||||
Description: "Run both old and streaming requests and log differences",
|
|
||||||
State: FeatureStateBeta,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
Name: "newDBLibrary",
|
Name: "newDBLibrary",
|
||||||
Description: "Use jmoiron/sqlx rather than xorm for a few backend services",
|
Description: "Use jmoiron/sqlx rather than xorm for a few backend services",
|
||||||
|
@ -155,10 +155,6 @@ const (
|
|||||||
// Enable streaming JSON parser for Prometheus datasource
|
// Enable streaming JSON parser for Prometheus datasource
|
||||||
FlagPrometheusStreamingJSONParser = "prometheusStreamingJSONParser"
|
FlagPrometheusStreamingJSONParser = "prometheusStreamingJSONParser"
|
||||||
|
|
||||||
// FlagPrometheusStreamingJSONParserTest
|
|
||||||
// Run both old and streaming requests and log differences
|
|
||||||
FlagPrometheusStreamingJSONParserTest = "prometheusStreamingJSONParserTest"
|
|
||||||
|
|
||||||
// FlagNewDBLibrary
|
// FlagNewDBLibrary
|
||||||
// Use jmoiron/sqlx rather than xorm for a few backend services
|
// Use jmoiron/sqlx rather than xorm for a few backend services
|
||||||
FlagNewDBLibrary = "newDBLibrary"
|
FlagNewDBLibrary = "newDBLibrary"
|
||||||
|
@ -2,31 +2,25 @@ package prometheus
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||||
"github.com/grafana/grafana-plugin-sdk-go/backend/datasource"
|
"github.com/grafana/grafana-plugin-sdk-go/backend/datasource"
|
||||||
"github.com/grafana/grafana-plugin-sdk-go/backend/instancemgmt"
|
"github.com/grafana/grafana-plugin-sdk-go/backend/instancemgmt"
|
||||||
"github.com/grafana/grafana/pkg/tsdb/prometheus/client"
|
|
||||||
"github.com/patrickmn/go-cache"
|
|
||||||
apiv1 "github.com/prometheus/client_golang/api/prometheus/v1"
|
|
||||||
"github.com/yudai/gojsondiff"
|
|
||||||
"github.com/yudai/gojsondiff/formatter"
|
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/infra/httpclient"
|
"github.com/grafana/grafana/pkg/infra/httpclient"
|
||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
"github.com/grafana/grafana/pkg/tsdb/prometheus/buffered"
|
"github.com/grafana/grafana/pkg/tsdb/prometheus/buffered"
|
||||||
|
"github.com/grafana/grafana/pkg/tsdb/prometheus/client"
|
||||||
"github.com/grafana/grafana/pkg/tsdb/prometheus/querydata"
|
"github.com/grafana/grafana/pkg/tsdb/prometheus/querydata"
|
||||||
"github.com/grafana/grafana/pkg/tsdb/prometheus/resource"
|
"github.com/grafana/grafana/pkg/tsdb/prometheus/resource"
|
||||||
|
"github.com/patrickmn/go-cache"
|
||||||
|
apiv1 "github.com/prometheus/client_golang/api/prometheus/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var plog = log.New("tsdb.prometheus")
|
var plog = log.New("tsdb.prometheus")
|
||||||
@ -103,36 +97,6 @@ func (s *Service) QueryData(ctx context.Context, req *backend.QueryDataRequest)
|
|||||||
return i.queryData.Execute(ctx, req)
|
return i.queryData.Execute(ctx, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
// To test the new client implementation this can be run and we do 2 requests and compare.
|
|
||||||
if s.features.IsEnabled(featuremgmt.FlagPrometheusStreamingJSONParserTest) {
|
|
||||||
var wg sync.WaitGroup
|
|
||||||
var streamData *backend.QueryDataResponse
|
|
||||||
var streamError error
|
|
||||||
|
|
||||||
var data *backend.QueryDataResponse
|
|
||||||
var err error
|
|
||||||
|
|
||||||
plog.FromContext(ctx).Debug("PrometheusStreamingJSONParserTest", "req", req)
|
|
||||||
|
|
||||||
wg.Add(1)
|
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
streamData, streamError = i.queryData.Execute(ctx, req)
|
|
||||||
}()
|
|
||||||
|
|
||||||
wg.Add(1)
|
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
data, err = i.buffered.ExecuteTimeSeriesQuery(ctx, req)
|
|
||||||
}()
|
|
||||||
|
|
||||||
wg.Wait()
|
|
||||||
|
|
||||||
// Report can take a while and we don't really need to wait for it.
|
|
||||||
go reportDiff(data, err, streamData, streamError)
|
|
||||||
return data, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return i.buffered.ExecuteTimeSeriesQuery(ctx, req)
|
return i.buffered.ExecuteTimeSeriesQuery(ctx, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,48 +151,3 @@ func ConvertAPIError(err error) error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func reportDiff(data *backend.QueryDataResponse, err error, streamData *backend.QueryDataResponse, streamError error) {
|
|
||||||
if err == nil && streamError != nil {
|
|
||||||
plog.Debug("PrometheusStreamingJSONParserTest error in streaming client", "err", streamError)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil && streamError == nil {
|
|
||||||
plog.Debug("PrometheusStreamingJSONParserTest error in buffer but not streaming", "err", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(data, streamData) {
|
|
||||||
plog.Debug("PrometheusStreamingJSONParserTest buffer and streaming data are different")
|
|
||||||
dataJson, jsonErr := json.MarshalIndent(data, "", "\t")
|
|
||||||
if jsonErr != nil {
|
|
||||||
plog.Debug("PrometheusStreamingJSONParserTest error marshaling data", "jsonErr", jsonErr)
|
|
||||||
}
|
|
||||||
streamingJson, jsonErr := json.MarshalIndent(streamData, "", "\t")
|
|
||||||
if jsonErr != nil {
|
|
||||||
plog.Debug("PrometheusStreamingJSONParserTest error marshaling streaming data", "jsonErr", jsonErr)
|
|
||||||
}
|
|
||||||
differ := gojsondiff.New()
|
|
||||||
d, diffErr := differ.Compare(dataJson, streamingJson)
|
|
||||||
if diffErr != nil {
|
|
||||||
plog.Debug("PrometheusStreamingJSONParserTest diff error", "err", diffErr)
|
|
||||||
}
|
|
||||||
config := formatter.AsciiFormatterConfig{
|
|
||||||
ShowArrayIndex: true,
|
|
||||||
Coloring: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
var aJson map[string]interface{}
|
|
||||||
unmarshallErr := json.Unmarshal(dataJson, &aJson)
|
|
||||||
if unmarshallErr != nil {
|
|
||||||
plog.Debug("PrometheusStreamingJSONParserTest unmarshall error", "err", unmarshallErr)
|
|
||||||
}
|
|
||||||
formatter := formatter.NewAsciiFormatter(aJson, config)
|
|
||||||
diffString, diffErr := formatter.Format(d)
|
|
||||||
if diffErr != nil {
|
|
||||||
plog.Debug("PrometheusStreamingJSONParserTest diff format error", "err", diffErr)
|
|
||||||
}
|
|
||||||
fmt.Println(diffString)
|
|
||||||
} else {
|
|
||||||
plog.Debug("PrometheusStreamingJSONParserTest responses are the same")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user