AzureMonitor: Move Application Insights and Insight Analytics to a deprecated package (#45834)

This commit is contained in:
Andres Martinez Gotor
2022-03-02 15:41:07 +01:00
committed by GitHub
parent 3427ae463d
commit 700f6863f2
33 changed files with 523 additions and 387 deletions
@@ -8,6 +8,9 @@ import (
"strings"
"github.com/grafana/grafana-plugin-sdk-go/backend/resource/httpadapter"
"github.com/grafana/grafana/pkg/tsdb/azuremonitor/azlog"
"github.com/grafana/grafana/pkg/tsdb/azuremonitor/deprecated"
"github.com/grafana/grafana/pkg/tsdb/azuremonitor/types"
)
func getTarget(original string) (target string, err error) {
@@ -63,16 +66,16 @@ func (s *httpServiceProxy) Do(rw http.ResponseWriter, req *http.Request, cli *ht
return rw
}
func (s *Service) getDataSourceFromHTTPReq(req *http.Request) (datasourceInfo, error) {
func (s *Service) getDataSourceFromHTTPReq(req *http.Request) (types.DatasourceInfo, error) {
ctx := req.Context()
pluginContext := httpadapter.PluginConfigFromContext(ctx)
i, err := s.im.Get(pluginContext)
if err != nil {
return datasourceInfo{}, nil
return types.DatasourceInfo{}, nil
}
ds, ok := i.(datasourceInfo)
ds, ok := i.(types.DatasourceInfo)
if !ok {
return datasourceInfo{}, fmt.Errorf("unable to convert datasource from service instance")
return types.DatasourceInfo{}, fmt.Errorf("unable to convert datasource from service instance")
}
return ds, nil
}
@@ -111,7 +114,7 @@ func (s *Service) handleResourceReq(subDataSource string) func(rw http.ResponseW
req.URL.Host = serviceURL.Host
req.URL.Scheme = serviceURL.Scheme
s.executors[subDataSource].resourceRequest(rw, req, service.HTTPClient)
s.executors[subDataSource].ResourceRequest(rw, req, service.HTTPClient)
}
}
@@ -120,8 +123,9 @@ func (s *Service) handleResourceReq(subDataSource string) func(rw http.ResponseW
func (s *Service) newResourceMux() *http.ServeMux {
mux := http.NewServeMux()
mux.HandleFunc("/azuremonitor/", s.handleResourceReq(azureMonitor))
mux.HandleFunc("/appinsights/", s.handleResourceReq(appInsights))
mux.HandleFunc("/loganalytics/", s.handleResourceReq(azureLogAnalytics))
mux.HandleFunc("/resourcegraph/", s.handleResourceReq(azureResourceGraph))
// Remove with Grafana 9
mux.HandleFunc("/appinsights/", s.handleResourceReq(deprecated.AppInsights))
return mux
}