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
@@ -0,0 +1,20 @@
package deprecated
import (
"net/http"
"github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
)
func GetAppInsightsMiddleware(url, appInsightsApiKey string) httpclient.Middleware {
if appInsightsApiKey != "" && url == AzAppInsights.URL || url == AzChinaAppInsights.URL {
// Inject API-Key for AppInsights
return httpclient.MiddlewareFunc(func(opts httpclient.Options, next http.RoundTripper) http.RoundTripper {
return httpclient.RoundTripperFunc(func(req *http.Request) (*http.Response, error) {
req.Header.Set("X-API-Key", appInsightsApiKey)
return next.RoundTrip(req)
})
})
}
return nil
}