Backend: use latest Go plugin sdk (#25909)
* backend: use latest go plugin sdk which fixes #25287 * update for Frame.Meta.Custom SDK changes
This commit is contained in:
@@ -162,10 +162,14 @@ func (e *AzureLogAnalyticsDatasource) executeQuery(ctx context.Context, query *A
|
||||
return queryResultError(err)
|
||||
}
|
||||
|
||||
setAdditionalFrameMeta(frame,
|
||||
err = setAdditionalFrameMeta(frame,
|
||||
query.Params.Get("query"),
|
||||
query.Model.Get("subscriptionId").MustString(),
|
||||
query.Model.Get("azureLogAnalytics").Get("workspace").MustString())
|
||||
if err != nil {
|
||||
frame.AppendNotices(data.Notice{Severity: data.NoticeSeverityWarning, Text: "could not add custom metadata: " + err.Error()})
|
||||
azlog.Warn("failed to add custom metadata to azure log analytics response", err)
|
||||
}
|
||||
|
||||
if query.ResultFormat == "time_series" {
|
||||
tsSchema := frame.TimeSeriesSchema()
|
||||
@@ -273,16 +277,28 @@ func (e *AzureLogAnalyticsDatasource) unmarshalResponse(res *http.Response) (Azu
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func setAdditionalFrameMeta(frame *data.Frame, query, subscriptionID, workspace string) {
|
||||
// LogAnalyticsMeta is a type for the a Frame's Meta's Custom property.
|
||||
type LogAnalyticsMeta struct {
|
||||
ColumnTypes []string `json:"azureColumnTypes"`
|
||||
Subscription string `json:"subscription"`
|
||||
Workspace string `json:"workspace"`
|
||||
EncodedQuery []byte `json:"encodedQuery"` // EncodedQuery is used for deep links.
|
||||
}
|
||||
|
||||
func setAdditionalFrameMeta(frame *data.Frame, query, subscriptionID, workspace string) error {
|
||||
frame.Meta.ExecutedQueryString = query
|
||||
frame.Meta.Custom["subscription"] = subscriptionID
|
||||
frame.Meta.Custom["workspace"] = workspace
|
||||
la, ok := frame.Meta.Custom.(*LogAnalyticsMeta)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type found for frame's custom metadata")
|
||||
}
|
||||
la.Subscription = subscriptionID
|
||||
la.Workspace = workspace
|
||||
encodedQuery, err := encodeQuery(query)
|
||||
if err == nil {
|
||||
frame.Meta.Custom["encodedQuery"] = encodedQuery
|
||||
return
|
||||
la.EncodedQuery = encodedQuery
|
||||
return nil
|
||||
}
|
||||
azlog.Error("failed to encode the query into the encodedQuery property")
|
||||
return fmt.Errorf("failed to encode the query into the encodedQuery property")
|
||||
}
|
||||
|
||||
// encodeQuery encodes the query in gzip so the frontend can build links.
|
||||
|
||||
@@ -52,7 +52,7 @@ func converterFrameForTable(t *AzureLogAnalyticsTable) (*data.FrameInputConverte
|
||||
}
|
||||
|
||||
fic.Frame.Meta = &data.FrameMeta{
|
||||
Custom: map[string]interface{}{"azureColumnTypes": colTypes},
|
||||
Custom: &LogAnalyticsMeta{ColumnTypes: colTypes},
|
||||
}
|
||||
|
||||
return fic, nil
|
||||
|
||||
@@ -41,7 +41,7 @@ func TestLogTableToFrame(t *testing.T) {
|
||||
}),
|
||||
)
|
||||
frame.Meta = &data.FrameMeta{
|
||||
Custom: map[string]interface{}{"azureColumnTypes": []string{"datetime", "string", "real"}},
|
||||
Custom: &LogAnalyticsMeta{ColumnTypes: []string{"datetime", "string", "real"}},
|
||||
}
|
||||
return frame
|
||||
},
|
||||
@@ -91,7 +91,7 @@ func TestLogTableToFrame(t *testing.T) {
|
||||
}),
|
||||
)
|
||||
frame.Meta = &data.FrameMeta{
|
||||
Custom: map[string]interface{}{"azureColumnTypes": []string{"string", "string", "string",
|
||||
Custom: &LogAnalyticsMeta{ColumnTypes: []string{"string", "string", "string",
|
||||
"string", "string", "real", "real", "int", "real", "datetime"}},
|
||||
}
|
||||
return frame
|
||||
@@ -113,7 +113,7 @@ func TestLogTableToFrame(t *testing.T) {
|
||||
data.NewField("XTimeSpan", nil, []*string{pointer.String("00:00:00.0000001")}),
|
||||
)
|
||||
frame.Meta = &data.FrameMeta{
|
||||
Custom: map[string]interface{}{"azureColumnTypes": []string{"bool", "string", "datetime",
|
||||
Custom: &LogAnalyticsMeta{ColumnTypes: []string{"bool", "string", "datetime",
|
||||
"dynamic", "guid", "int", "long", "real", "timespan"}},
|
||||
}
|
||||
return frame
|
||||
|
||||
Reference in New Issue
Block a user