chore: remove all remaining uses of golang.org/x/net/context (#47564)

* chore: remove all remaining uses of  golang.org/x/net/context

This PR finishes the work started in #47532, replacing all calls to that package with the stdlib context and using http.NewRequestWithContext to include the context where necessary.

Bonus: small formatting fixes to goimports in these files.

closes #44178

* tweak: use context.Background in favor of TODO for tests
This commit is contained in:
Kristin Laemmert
2022-04-11 14:20:10 -04:00
committed by GitHub
parent 03ba91e8a4
commit 8f6877e12a
10 changed files with 36 additions and 38 deletions
@@ -14,6 +14,8 @@ import (
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/data"
"go.opentelemetry.io/otel/attribute"
"github.com/grafana/grafana/pkg/infra/tracing"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/tsdb/azuremonitor/azlog"
@@ -21,8 +23,6 @@ import (
azTime "github.com/grafana/grafana/pkg/tsdb/azuremonitor/time"
"github.com/grafana/grafana/pkg/tsdb/azuremonitor/types"
"github.com/grafana/grafana/pkg/util/errutil"
"go.opentelemetry.io/otel/attribute"
"golang.org/x/net/context/ctxhttp"
)
// AzureMonitorDatasource calls the Azure Monitor API - one of the four API's supported
@@ -179,7 +179,7 @@ func (e *AzureMonitorDatasource) executeQuery(ctx context.Context, query *types.
azlog.Debug("AzureMonitor", "Request ApiURL", req.URL.String())
azlog.Debug("AzureMonitor", "Target", query.Target)
res, err := ctxhttp.Do(ctx, cli, req)
res, err := cli.Do(req)
if err != nil {
dataResponse.Error = err
return dataResponse
@@ -212,7 +212,7 @@ func (e *AzureMonitorDatasource) executeQuery(ctx context.Context, query *types.
}
func (e *AzureMonitorDatasource) createRequest(ctx context.Context, dsInfo types.DatasourceInfo, url string) (*http.Request, error) {
req, err := http.NewRequest(http.MethodGet, url, nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
if err != nil {
azlog.Debug("Failed to create request", "error", err)
return nil, errutil.Wrap("Failed to create request", err)