Commit c1ede4fc by Kyle Brandt Committed by GitHub

backend: use latest go plugin sdk (0.74.0) to sort wide frames (#26207)

This makes it so results are more stable between refreshes of data and fixes sorting issues with Azure Application Insights service as well as the two Azure Analytics services.

fixes #22937
parent 396ff9f4
...@@ -31,7 +31,7 @@ require ( ...@@ -31,7 +31,7 @@ require (
github.com/gorilla/websocket v1.4.1 github.com/gorilla/websocket v1.4.1
github.com/gosimple/slug v1.4.2 github.com/gosimple/slug v1.4.2
github.com/grafana/grafana-plugin-model v0.0.0-20190930120109-1fc953a61fb4 github.com/grafana/grafana-plugin-model v0.0.0-20190930120109-1fc953a61fb4
github.com/grafana/grafana-plugin-sdk-go v0.71.0 github.com/grafana/grafana-plugin-sdk-go v0.74.0
github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd
github.com/hashicorp/go-plugin v1.2.2 github.com/hashicorp/go-plugin v1.2.2
github.com/hashicorp/go-version v1.1.0 github.com/hashicorp/go-version v1.1.0
......
...@@ -151,8 +151,8 @@ github.com/gosimple/slug v1.4.2 h1:jDmprx3q/9Lfk4FkGZtvzDQ9Cj9eAmsjzeQGp24PeiQ= ...@@ -151,8 +151,8 @@ github.com/gosimple/slug v1.4.2 h1:jDmprx3q/9Lfk4FkGZtvzDQ9Cj9eAmsjzeQGp24PeiQ=
github.com/gosimple/slug v1.4.2/go.mod h1:ER78kgg1Mv0NQGlXiDe57DpCyfbNywXXZ9mIorhxAf0= github.com/gosimple/slug v1.4.2/go.mod h1:ER78kgg1Mv0NQGlXiDe57DpCyfbNywXXZ9mIorhxAf0=
github.com/grafana/grafana-plugin-model v0.0.0-20190930120109-1fc953a61fb4 h1:SPdxCL9BChFTlyi0Khv64vdCW4TMna8+sxL7+Chx+Ag= github.com/grafana/grafana-plugin-model v0.0.0-20190930120109-1fc953a61fb4 h1:SPdxCL9BChFTlyi0Khv64vdCW4TMna8+sxL7+Chx+Ag=
github.com/grafana/grafana-plugin-model v0.0.0-20190930120109-1fc953a61fb4/go.mod h1:nc0XxBzjeGcrMltCDw269LoWF9S8ibhgxolCdA1R8To= github.com/grafana/grafana-plugin-model v0.0.0-20190930120109-1fc953a61fb4/go.mod h1:nc0XxBzjeGcrMltCDw269LoWF9S8ibhgxolCdA1R8To=
github.com/grafana/grafana-plugin-sdk-go v0.71.0 h1:dF2H1O03aTekFujss+iU/dcrvdDMsk16URbyExNJxqY= github.com/grafana/grafana-plugin-sdk-go v0.74.0 h1:UdyX8dJ5HoM8JoUk6I7zIt7rFbjkAeAXVbqQRDxZ5Eg=
github.com/grafana/grafana-plugin-sdk-go v0.71.0/go.mod h1:NvxLzGkVhnoBKwzkst6CFfpMFKwAdIUZ1q8ssuLeF60= github.com/grafana/grafana-plugin-sdk-go v0.74.0/go.mod h1:NvxLzGkVhnoBKwzkst6CFfpMFKwAdIUZ1q8ssuLeF60=
github.com/grpc-ecosystem/go-grpc-middleware v1.2.0 h1:0IKlLyQ3Hs9nDaiK5cSHAGmcQEIC8l2Ts1u6x5Dfrqg= github.com/grpc-ecosystem/go-grpc-middleware v1.2.0 h1:0IKlLyQ3Hs9nDaiK5cSHAGmcQEIC8l2Ts1u6x5Dfrqg=
github.com/grpc-ecosystem/go-grpc-middleware v1.2.0/go.mod h1:mJzapYve32yjrKlk9GbyCZHuPgZsrbyIbyKhSzOpg6s= github.com/grpc-ecosystem/go-grpc-middleware v1.2.0/go.mod h1:mJzapYve32yjrKlk9GbyCZHuPgZsrbyIbyKhSzOpg6s=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=
......
...@@ -106,6 +106,11 @@ func InsightsMetricsResultToFrame(mr MetricsResult, metric, agg string, dimensio ...@@ -106,6 +106,11 @@ func InsightsMetricsResultToFrame(mr MetricsResult, metric, agg string, dimensio
} }
rowCounter++ rowCounter++
} }
if err := data.SortWideFrameFields(frame, dimensions...); err != nil {
return nil, err
}
return frame, nil return frame, nil
} }
......
...@@ -67,7 +67,7 @@ func TestInsightsMetricsResultToFrame(t *testing.T) { ...@@ -67,7 +67,7 @@ func TestInsightsMetricsResultToFrame(t *testing.T) {
}, },
}, },
{ {
name: "segmented series", name: "multi segmented series",
testFile: "applicationinsights/4-application-insights-response-metrics-multi-segmented.json", testFile: "applicationinsights/4-application-insights-response-metrics-multi-segmented.json",
metric: "traces/count", metric: "traces/count",
agg: "sum", agg: "sum",
...@@ -78,12 +78,8 @@ func TestInsightsMetricsResultToFrame(t *testing.T) { ...@@ -78,12 +78,8 @@ func TestInsightsMetricsResultToFrame(t *testing.T) {
time.Date(2020, 6, 25, 16, 15, 32, 14e7, time.UTC), time.Date(2020, 6, 25, 16, 15, 32, 14e7, time.UTC),
time.Date(2020, 6, 25, 16, 16, 0, 0, time.UTC), time.Date(2020, 6, 25, 16, 16, 0, 0, time.UTC),
}), }),
data.NewField("traces/count", data.Labels{"client/city": "Washington", "client/countryOrRegion": "United States"}, []*float64{ data.NewField("traces/count", data.Labels{"client/city": "Tokyo", "client/countryOrRegion": "Japan"}, []*float64{
pointer.Float64(2),
nil, nil,
}),
data.NewField("traces/count", data.Labels{"client/city": "Des Moines", "client/countryOrRegion": "United States"}, []*float64{
pointer.Float64(2),
pointer.Float64(1), pointer.Float64(1),
}), }),
data.NewField("traces/count", data.Labels{"client/city": "", "client/countryOrRegion": "United States"}, []*float64{ data.NewField("traces/count", data.Labels{"client/city": "", "client/countryOrRegion": "United States"}, []*float64{
...@@ -94,10 +90,14 @@ func TestInsightsMetricsResultToFrame(t *testing.T) { ...@@ -94,10 +90,14 @@ func TestInsightsMetricsResultToFrame(t *testing.T) {
nil, nil,
pointer.Float64(3), pointer.Float64(3),
}), }),
data.NewField("traces/count", data.Labels{"client/city": "Tokyo", "client/countryOrRegion": "Japan"}, []*float64{ data.NewField("traces/count", data.Labels{"client/city": "Des Moines", "client/countryOrRegion": "United States"}, []*float64{
nil, pointer.Float64(2),
pointer.Float64(1), pointer.Float64(1),
}), }),
data.NewField("traces/count", data.Labels{"client/city": "Washington", "client/countryOrRegion": "United States"}, []*float64{
pointer.Float64(2),
nil,
}),
) )
return frame return frame
...@@ -116,31 +116,28 @@ func TestInsightsMetricsResultToFrame(t *testing.T) { ...@@ -116,31 +116,28 @@ func TestInsightsMetricsResultToFrame(t *testing.T) {
time.Date(2020, 6, 25, 16, 15, 32, 14e7, time.UTC), time.Date(2020, 6, 25, 16, 15, 32, 14e7, time.UTC),
time.Date(2020, 6, 25, 16, 16, 0, 0, time.UTC), time.Date(2020, 6, 25, 16, 16, 0, 0, time.UTC),
}), }),
data.NewField("traces/count", data.Labels{"client/city": "Tokyo", "client/countryOrRegion": "Japan"}, []*float64{
data.NewField("traces/count", data.Labels{"client/city": "Washington", "client/countryOrRegion": "United States"}, []*float64{
pointer.Float64(2),
nil, nil,
}).SetConfig(&data.FieldConfig{DisplayName: "traces/count: Country,City: United States,Washington"}),
data.NewField("traces/count", data.Labels{"client/city": "Des Moines", "client/countryOrRegion": "United States"}, []*float64{
pointer.Float64(2),
pointer.Float64(1), pointer.Float64(1),
}).SetConfig(&data.FieldConfig{DisplayName: "traces/count: Country,City: United States,Des Moines"}), }).SetConfig(&data.FieldConfig{DisplayName: "traces/count: Country,City: Japan,Tokyo"}),
data.NewField("traces/count", data.Labels{"client/city": "", "client/countryOrRegion": "United States"}, []*float64{ data.NewField("traces/count", data.Labels{"client/city": "", "client/countryOrRegion": "United States"}, []*float64{
nil, nil,
pointer.Float64(11), pointer.Float64(11),
}).SetConfig(&data.FieldConfig{DisplayName: "traces/count: Country,City: United States,"}), }).SetConfig(&data.FieldConfig{DisplayName: "traces/count: Country,City: United States,"}),
data.NewField("traces/count", data.Labels{"client/city": "Chicago", "client/countryOrRegion": "United States"}, []*float64{ data.NewField("traces/count", data.Labels{"client/city": "Chicago", "client/countryOrRegion": "United States"}, []*float64{
nil, nil,
pointer.Float64(3), pointer.Float64(3),
}).SetConfig(&data.FieldConfig{DisplayName: "traces/count: Country,City: United States,Chicago"}), }).SetConfig(&data.FieldConfig{DisplayName: "traces/count: Country,City: United States,Chicago"}),
data.NewField("traces/count", data.Labels{"client/city": "Tokyo", "client/countryOrRegion": "Japan"}, []*float64{ data.NewField("traces/count", data.Labels{"client/city": "Des Moines", "client/countryOrRegion": "United States"}, []*float64{
nil, pointer.Float64(2),
pointer.Float64(1), pointer.Float64(1),
}).SetConfig(&data.FieldConfig{DisplayName: "traces/count: Country,City: Japan,Tokyo"}), }).SetConfig(&data.FieldConfig{DisplayName: "traces/count: Country,City: United States,Des Moines"}),
data.NewField("traces/count", data.Labels{"client/city": "Washington", "client/countryOrRegion": "United States"}, []*float64{
pointer.Float64(2),
nil,
}).SetConfig(&data.FieldConfig{DisplayName: "traces/count: Country,City: United States,Washington"}),
) )
return frame return frame
......
...@@ -100,14 +100,6 @@ func TestFrameToSeriesSlice(t *testing.T) { ...@@ -100,14 +100,6 @@ func TestFrameToSeriesSlice(t *testing.T) {
}, },
}, },
&TimeSeries{ &TimeSeries{
Name: "Values Int64",
Tags: map[string]string{"Animal Factor": "cat", "Location": "Florida"},
Points: TimeSeriesPoints{
TimePoint{null.FloatFrom(1), null.FloatFrom(1577934240000)},
TimePoint{null.FloatFrom(3), null.FloatFrom(1577934270000)},
},
},
&TimeSeries{
Name: "Values Floats", Name: "Values Floats",
Tags: map[string]string{"Animal Factor": "sloth", "Location": "Central & South America"}, Tags: map[string]string{"Animal Factor": "sloth", "Location": "Central & South America"},
Points: TimeSeriesPoints{ Points: TimeSeriesPoints{
...@@ -117,6 +109,14 @@ func TestFrameToSeriesSlice(t *testing.T) { ...@@ -117,6 +109,14 @@ func TestFrameToSeriesSlice(t *testing.T) {
}, },
&TimeSeries{ &TimeSeries{
Name: "Values Int64", Name: "Values Int64",
Tags: map[string]string{"Animal Factor": "cat", "Location": "Florida"},
Points: TimeSeriesPoints{
TimePoint{null.FloatFrom(1), null.FloatFrom(1577934240000)},
TimePoint{null.FloatFrom(3), null.FloatFrom(1577934270000)},
},
},
&TimeSeries{
Name: "Values Int64",
Tags: map[string]string{"Animal Factor": "sloth", "Location": "Central & South America"}, Tags: map[string]string{"Animal Factor": "sloth", "Location": "Central & South America"},
Points: TimeSeriesPoints{ Points: TimeSeriesPoints{
TimePoint{null.FloatFrom(2), null.FloatFrom(1577934240000)}, TimePoint{null.FloatFrom(2), null.FloatFrom(1577934240000)},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment