AzureMonitor: Add custom header support to Azure Monitor (#60269)
* Add integration test for Azure Monitor - Add Azure Monitor to datasource types - Update instance creation to correctly set HTTP client options - Combine custom azure headers and custom grafana headers on HTTP client creation - Update HTTP client tests * Test custom azure headers
This commit is contained in:
@@ -68,9 +68,9 @@ type Service struct {
|
||||
tracer tracing.Tracer
|
||||
}
|
||||
|
||||
func getDatasourceService(cfg *setting.Cfg, clientProvider *httpclient.Provider, dsInfo types.DatasourceInfo, routeName string) (types.DatasourceService, error) {
|
||||
func getDatasourceService(cfg *setting.Cfg, clientProvider *httpclient.Provider, dsInfo types.DatasourceInfo, routeName string, httpClientOptions httpclient.Options) (types.DatasourceService, error) {
|
||||
route := dsInfo.Routes[routeName]
|
||||
client, err := newHTTPClient(route, dsInfo, cfg, clientProvider)
|
||||
client, err := newHTTPClient(route, dsInfo, cfg, clientProvider, httpClientOptions)
|
||||
if err != nil {
|
||||
return types.DatasourceService{}, err
|
||||
}
|
||||
@@ -86,13 +86,17 @@ func NewInstanceSettings(cfg *setting.Cfg, clientProvider *httpclient.Provider,
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error reading settings: %w", err)
|
||||
}
|
||||
|
||||
jsonDataObj := map[string]interface{}{}
|
||||
err = json.Unmarshal(settings.JSONData, &jsonDataObj)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error reading settings: %w", err)
|
||||
}
|
||||
|
||||
httpClientOpts, err := settings.HTTPClientOptions()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error getting http options: %w", err)
|
||||
}
|
||||
|
||||
azMonitorSettings := types.AzureMonitorSettings{}
|
||||
err = json.Unmarshal(settings.JSONData, &azMonitorSettings)
|
||||
if err != nil {
|
||||
@@ -126,7 +130,7 @@ func NewInstanceSettings(cfg *setting.Cfg, clientProvider *httpclient.Provider,
|
||||
}
|
||||
|
||||
for routeName := range executors {
|
||||
service, err := getDatasourceService(cfg, clientProvider, model, routeName)
|
||||
service, err := getDatasourceService(cfg, clientProvider, model, routeName, httpClientOpts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user