mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Prometheus: Move converter in prometheus package (#82269)
* use jsoniter from sdk * move converter into the prometheus * remove jsonitere * unit test * remove redundant ownership
This commit is contained in:
parent
45c7393564
commit
916a7bbb08
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@ -269,7 +269,6 @@
|
||||
/pkg/services/searchV2/ @grafana/grafana-app-platform-squad
|
||||
/pkg/services/store/ @grafana/grafana-app-platform-squad
|
||||
/pkg/infra/filestorage/ @grafana/grafana-app-platform-squad
|
||||
/pkg/util/converter/ @grafana/grafana-app-platform-squad
|
||||
/pkg/modules/ @grafana/grafana-app-platform-squad
|
||||
/pkg/kindsysreport/ @grafana/grafana-app-platform-squad
|
||||
/pkg/services/grpcserver/ @grafana/grafana-app-platform-squad
|
||||
|
@ -20,10 +20,11 @@ import (
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||
"github.com/grafana/grafana/pkg/tsdb/loki/instrumentation"
|
||||
"github.com/grafana/grafana/pkg/util/converter"
|
||||
"github.com/grafana/grafana/pkg/tsdb/prometheus/converter"
|
||||
)
|
||||
|
||||
type LokiAPI struct {
|
||||
@ -334,7 +335,7 @@ func getSupportingQueryHeaderValue(req *http.Request, supportingQueryType Suppor
|
||||
value = "datasample"
|
||||
case SupportingQueryInfiniteScroll:
|
||||
value = "infinitescroll"
|
||||
default: //ignore
|
||||
default: // ignore
|
||||
}
|
||||
|
||||
return value
|
||||
|
@ -1,15 +1,14 @@
|
||||
package converter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
sdkjsoniter "github.com/grafana/grafana-plugin-sdk-go/data/utils/jsoniter"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/experimental"
|
||||
"github.com/grafana/grafana/pkg/infra/httpclient"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -44,29 +43,6 @@ func TestReadPromFrames(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadLimited(t *testing.T) {
|
||||
for _, name := range files {
|
||||
p := path.Join("testdata", name+".json")
|
||||
stat, err := os.Stat(p)
|
||||
require.NoError(t, err)
|
||||
size := stat.Size()
|
||||
|
||||
for i := int64(10); i < size-1; i += size / 10 {
|
||||
t.Run(fmt.Sprintf("%v_%v", name, i), func(t *testing.T) {
|
||||
//nolint:gosec
|
||||
f, err := os.Open(p)
|
||||
require.NoError(t, err)
|
||||
mbr := httpclient.MaxBytesReader(f, i)
|
||||
|
||||
iter := jsoniter.Parse(jsoniter.ConfigDefault, mbr, 1024)
|
||||
rsp := ReadPrometheusStyleResult(iter, Options{})
|
||||
|
||||
require.ErrorContains(t, rsp.Error, "response body too large")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func runScenario(name string, opts Options) func(t *testing.T) {
|
||||
return func(t *testing.T) {
|
||||
// Safe to disable, this is a test.
|
||||
@ -74,7 +50,7 @@ func runScenario(name string, opts Options) func(t *testing.T) {
|
||||
f, err := os.Open(path.Join("testdata", name+".json"))
|
||||
require.NoError(t, err)
|
||||
|
||||
iter := jsoniter.Parse(jsoniter.ConfigDefault, f, 1024)
|
||||
iter := jsoniter.Parse(sdkjsoniter.ConfigDefault, f, 1024)
|
||||
rsp := ReadPrometheusStyleResult(iter, opts)
|
||||
|
||||
if strings.Contains(name, "error") {
|
@ -12,10 +12,10 @@ import (
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
|
||||
"github.com/grafana/grafana/pkg/tsdb/prometheus/converter"
|
||||
"github.com/grafana/grafana/pkg/tsdb/prometheus/models"
|
||||
"github.com/grafana/grafana/pkg/tsdb/prometheus/querydata/exemplar"
|
||||
"github.com/grafana/grafana/pkg/tsdb/prometheus/utils"
|
||||
"github.com/grafana/grafana/pkg/util/converter"
|
||||
)
|
||||
|
||||
func (s *QueryData) parseResponse(ctx context.Context, q *models.Query, res *http.Response, enablePrometheusDataplaneFlag bool) backend.DataResponse {
|
||||
|
Loading…
Reference in New Issue
Block a user