Cloudwatch: Remove core imports from infra/log (#81543)

* Cloudwatch: use logging from plugin-sdk-go instead of infra/log
* Add a link to the TODO issue for moving `instrumentContext`
This commit is contained in:
Nathan Vērzemnieks
2024-02-07 13:53:05 +01:00
committed by GitHub
parent c16cb7ed3c
commit b5f26560c2
28 changed files with 211 additions and 172 deletions
@@ -16,6 +16,7 @@ import (
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/backend/datasource"
"github.com/grafana/grafana-plugin-sdk-go/backend/instancemgmt"
"github.com/grafana/grafana-plugin-sdk-go/backend/log"
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/mocks"
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models"
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models/resources"
@@ -67,7 +68,7 @@ func Test_CloudWatch_CallResource_Integration_Test(t *testing.T) {
{MetricName: aws.String("Test_MetricName8"), Dimensions: []*cloudwatch.Dimension{{Name: aws.String("Test_DimensionName4"), Value: aws.String("Value1")}}},
{MetricName: aws.String("Test_MetricName9"), Dimensions: []*cloudwatch.Dimension{{Name: aws.String("Test_DimensionName1"), Value: aws.String("Value2")}}},
}, MetricsPerPage: 100}
executor := newExecutor(im, &fakeSessionCache{})
executor := newExecutor(im, &fakeSessionCache{}, log.NewNullLogger())
req := &backend.CallResourceRequest{
Method: "GET",
@@ -103,7 +104,8 @@ func Test_CloudWatch_CallResource_Integration_Test(t *testing.T) {
{MetricName: aws.String("Test_MetricName8"), Dimensions: []*cloudwatch.Dimension{{Name: aws.String("Test_DimensionName4")}}},
{MetricName: aws.String("Test_MetricName9"), Dimensions: []*cloudwatch.Dimension{{Name: aws.String("Test_DimensionName1")}}},
}, MetricsPerPage: 2}
executor := newExecutor(im, &fakeSessionCache{})
executor := newExecutor(im, &fakeSessionCache{}, log.NewNullLogger())
req := &backend.CallResourceRequest{
Method: "GET",
Path: `/dimension-keys?region=us-east-2&namespace=AWS/EC2&metricName=CPUUtilization&dimensionFilters={"NodeID":["Shared"],"stage":["QueryCommit"]}`,
@@ -127,7 +129,7 @@ func Test_CloudWatch_CallResource_Integration_Test(t *testing.T) {
t.Run("Should handle standard dimension key query and return hard coded keys", func(t *testing.T) {
im := defaultTestInstanceManager()
api = mocks.FakeMetricsAPI{}
executor := newExecutor(im, &fakeSessionCache{})
executor := newExecutor(im, &fakeSessionCache{}, log.NewNullLogger())
req := &backend.CallResourceRequest{
Method: "GET",
@@ -152,7 +154,8 @@ func Test_CloudWatch_CallResource_Integration_Test(t *testing.T) {
t.Run("Should handle custom namespace dimension key query and return hard coded keys", func(t *testing.T) {
im := defaultTestInstanceManager()
api = mocks.FakeMetricsAPI{}
executor := newExecutor(im, &fakeSessionCache{})
executor := newExecutor(im, &fakeSessionCache{}, log.NewNullLogger())
req := &backend.CallResourceRequest{
Method: "GET",
Path: `/dimension-keys?region=us-east-2&namespace=AWS/CloudSearch&metricName=CPUUtilization`,
@@ -187,7 +190,7 @@ func Test_CloudWatch_CallResource_Integration_Test(t *testing.T) {
{MetricName: aws.String("Test_MetricName8"), Namespace: aws.String("AWS/EC2"), Dimensions: []*cloudwatch.Dimension{{Name: aws.String("Test_DimensionName4")}}},
{MetricName: aws.String("Test_MetricName9"), Namespace: aws.String("AWS/EC2"), Dimensions: []*cloudwatch.Dimension{{Name: aws.String("Test_DimensionName1")}}},
}, MetricsPerPage: 2}
executor := newExecutor(im, &fakeSessionCache{})
executor := newExecutor(im, &fakeSessionCache{}, log.NewNullLogger())
req := &backend.CallResourceRequest{
Method: "GET",
@@ -224,7 +227,7 @@ func Test_CloudWatch_CallResource_Integration_Test(t *testing.T) {
},
},
}, nil)
executor := newExecutor(im, &fakeSessionCache{})
executor := newExecutor(im, &fakeSessionCache{}, log.NewNullLogger())
req := &backend.CallResourceRequest{
Method: "GET",
@@ -246,7 +249,7 @@ func Test_CloudWatch_CallResource_Integration_Test(t *testing.T) {
t.Run("Should handle region requests and return regions from the api", func(t *testing.T) {
im := defaultTestInstanceManager()
executor := newExecutor(im, &fakeSessionCache{})
executor := newExecutor(im, &fakeSessionCache{}, log.NewNullLogger())
req := &backend.CallResourceRequest{
Method: "GET",
Path: `/regions`,
@@ -272,7 +275,7 @@ func Test_CloudWatch_CallResource_Integration_Test(t *testing.T) {
}}, nil
})
executor := newExecutor(imWithoutDefaultRegion, &fakeSessionCache{})
executor := newExecutor(imWithoutDefaultRegion, &fakeSessionCache{}, log.NewNullLogger())
req := &backend.CallResourceRequest{
Method: "GET",
Path: `/regions`,