Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] address linting failures #31286

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions receiver/aerospikereceiver/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestAerospike_Info(t *testing.T) {
logger: logger.Sugar(),
}

nodeGetterFactoryFunc := func(cfg *clientConfig, policy *as.ClientPolicy, authEnabled bool) (nodeGetter, error) {
nodeGetterFactoryFunc := func(*clientConfig, *as.ClientPolicy, bool) (nodeGetter, error) {
return testCluster, nil
}

Expand Down Expand Up @@ -111,7 +111,7 @@ func TestAerospike_NamespaceInfo(t *testing.T) {
logger: logger.Sugar(),
}

nodeGetterFactoryFunc := func(cfg *clientConfig, policy *as.ClientPolicy, authEnabled bool) (nodeGetter, error) {
nodeGetterFactoryFunc := func(*clientConfig, *as.ClientPolicy, bool) (nodeGetter, error) {
return testCluster, nil
}

Expand Down Expand Up @@ -170,7 +170,7 @@ func TestAerospike_NamespaceInfo_Negative(t *testing.T) {
testClusterNeg.On("GetNodes").Return(testNodesNeg)
testClusterNeg.On("Close").Return()

nodeGetterFactoryFuncNeg := func(cfg *clientConfig, policy *as.ClientPolicy, authEnabled bool) (nodeGetter, error) {
nodeGetterFactoryFuncNeg := func(*clientConfig, *as.ClientPolicy, bool) (nodeGetter, error) {
return testClusterNeg, nil
}

Expand Down Expand Up @@ -202,7 +202,7 @@ func TestAerospike_NamespaceInfo_Negative(t *testing.T) {
testClusterNeg.On("GetNodes").Return(testNodesNeg)
testClusterNeg.On("Close").Return()

nodeGetterFactoryFuncNeg = func(cfg *clientConfig, policy *as.ClientPolicy, authEnabled bool) (nodeGetter, error) {
nodeGetterFactoryFuncNeg = func(*clientConfig, *as.ClientPolicy, bool) (nodeGetter, error) {
return testClusterNeg, nil
}

Expand Down
2 changes: 1 addition & 1 deletion receiver/aerospikereceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestNewAerospikeReceiver_BadEndpoint(t *testing.T) {
},
}

cs, err := consumer.NewMetrics(func(ctx context.Context, ld pmetric.Metrics) error { return nil })
cs, err := consumer.NewMetrics(func(context.Context, pmetric.Metrics) error { return nil })
require.NoError(t, err)

for _, tc := range testCases {
Expand Down
10 changes: 5 additions & 5 deletions receiver/apachesparkreceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,25 @@ func TestScraper(t *testing.T) {
}{
{
desc: "Exits on failure to get app ids",
setupMockClient: func(t *testing.T) client {
setupMockClient: func(*testing.T) client {
mockClient := mocks.MockClient{}
mockClient.On("Applications").Return(nil, errors.New("could not retrieve app ids"))
return &mockClient
},
expectedMetricGen: func(t *testing.T) pmetric.Metrics {
expectedMetricGen: func(*testing.T) pmetric.Metrics {
return pmetric.NewMetrics()
},
config: createDefaultConfig().(*Config),
expectedErr: errors.Join(errFailedAppIDCollection, errors.New("could not retrieve app ids")),
},
{
desc: "No Matching Allowed Apps",
setupMockClient: func(t *testing.T) client {
setupMockClient: func(*testing.T) client {
mockClient := mocks.MockClient{}
mockClient.On("Applications").Return([]models.Application{}, nil)
return &mockClient
},
expectedMetricGen: func(t *testing.T) pmetric.Metrics {
expectedMetricGen: func(*testing.T) pmetric.Metrics {
return pmetric.NewMetrics()
},
config: &Config{ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
Expand All @@ -78,7 +78,7 @@ func TestScraper(t *testing.T) {
},
{
desc: "Successful Full Empty Collection",
setupMockClient: func(t *testing.T) client {
setupMockClient: func(*testing.T) client {
mockClient := mocks.MockClient{}
mockClient.On("ClusterStats").Return(&models.ClusterProperties{}, nil)
mockClient.On("Applications").Return([]models.Application{}, nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ type Option func(*Cadvisor)

// WithDecorator constructs an option for configuring the metric decorator
func WithDecorator(_ any) Option {
return func(c *Cadvisor) {
return func(*Cadvisor) {
// do nothing
}
}

func WithECSInfoCreator(_ any) Option {
return func(c *Cadvisor) {
return func(*Cadvisor) {
// do nothing
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,16 @@ func TestEBSVolume(t *testing.T) {
assert.Equal(t, "aws://us-west-2/vol-0c241693efb58734a", e.getEBSVolumeID("/dev/nvme0n2"))
assert.Equal(t, "", e.getEBSVolumeID("/dev/invalid"))

ebsIds := e.extractEbsIDsUsedByKubernetes()
assert.Equal(t, 1, len(ebsIds))
assert.Equal(t, "aws://us-west-2b/vol-0d9f0816149eb2050", ebsIds["/dev/nvme1n1"])
ebsIDs := e.extractEbsIDsUsedByKubernetes()
assert.Equal(t, 1, len(ebsIDs))
assert.Equal(t, "aws://us-west-2b/vol-0d9f0816149eb2050", ebsIDs["/dev/nvme1n1"])

// set e.hostMounts to an invalid path
hostMountsOption = func(e *ebsVolume) {
e.hostMounts = "/an-invalid-path"
}
e = newEBSVolume(ctx, sess, "instanceId", "us-west-2", time.Millisecond, zap.NewNop(),
clientOption, maxJitterOption, hostMountsOption, LstatOption, evalSymLinksOption)
ebsIds = e.extractEbsIDsUsedByKubernetes()
assert.Equal(t, 0, len(ebsIds))
ebsIDs = e.extractEbsIDsUsedByKubernetes()
assert.Equal(t, 0, len(ebsIDs))
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
func TestNodeCapacity(t *testing.T) {
// no proc directory
lstatOption := func(nc *nodeCapacity) {
nc.osLstat = func(name string) (os.FileInfo, error) {
nc.osLstat = func(string) (os.FileInfo, error) {
return nil, os.ErrNotExist
}
}
Expand All @@ -28,18 +28,18 @@ func TestNodeCapacity(t *testing.T) {

// can't set environment variables
lstatOption = func(nc *nodeCapacity) {
nc.osLstat = func(name string) (os.FileInfo, error) {
nc.osLstat = func(string) (os.FileInfo, error) {
return nil, nil
}
}

virtualMemOption := func(nc *nodeCapacity) {
nc.virtualMemory = func(ctx context.Context) (*mem.VirtualMemoryStat, error) {
nc.virtualMemory = func(context.Context) (*mem.VirtualMemoryStat, error) {
return nil, errors.New("error")
}
}
cpuInfoOption := func(nc *nodeCapacity) {
nc.cpuInfo = func(ctx context.Context) ([]cpu.InfoStat, error) {
nc.cpuInfo = func(context.Context) ([]cpu.InfoStat, error) {
return nil, errors.New("error")
}
}
Expand All @@ -51,14 +51,14 @@ func TestNodeCapacity(t *testing.T) {

// normal case where everything is working
virtualMemOption = func(nc *nodeCapacity) {
nc.virtualMemory = func(ctx context.Context) (*mem.VirtualMemoryStat, error) {
nc.virtualMemory = func(context.Context) (*mem.VirtualMemoryStat, error) {
return &mem.VirtualMemoryStat{
Total: 1024,
}, nil
}
}
cpuInfoOption = func(nc *nodeCapacity) {
nc.cpuInfo = func(ctx context.Context) ([]cpu.InfoStat, error) {
nc.cpuInfo = func(context.Context) ([]cpu.InfoStat, error) {
return []cpu.InfoStat{
{},
{},
Expand Down
28 changes: 14 additions & 14 deletions receiver/awsxrayreceiver/internal/translator/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,19 +663,19 @@ func TestTranslation(t *testing.T) {
{
testCase: "TranslateInvalidNamespace",
samplePath: filepath.Join("../../../../internal/aws/xray", "testdata", "invalidNamespace.txt"),
expectedResourceAttrs: func(seg *awsxray.Segment) map[string]any {
expectedResourceAttrs: func(*awsxray.Segment) map[string]any {
return nil
},
expectedRecord: xray.TelemetryRecord{
SegmentsReceivedCount: aws.Int64(18),
SegmentsRejectedCount: aws.Int64(18),
},
propsPerSpan: func(_ string, _ *testing.T, seg *awsxray.Segment) []perSpanProperties {
propsPerSpan: func(string, *testing.T, *awsxray.Segment) []perSpanProperties {
return nil
},
verification: func(testCase string,
actualSeg *awsxray.Segment,
expectedRs ptrace.ResourceSpans, actualTraces ptrace.Traces, err error) {
_ ptrace.ResourceSpans, _ ptrace.Traces, err error) {
assert.EqualError(t, err,
fmt.Sprintf("unexpected namespace: %s",
*actualSeg.Subsegments[0].Subsegments[0].Namespace),
Expand Down Expand Up @@ -831,19 +831,19 @@ func TestTranslation(t *testing.T) {
{
testCase: "TranslateInvalidSqlUrl",
samplePath: filepath.Join("../../../../internal/aws/xray", "testdata", "indepSubsegmentWithInvalidSqlUrl.txt"),
expectedResourceAttrs: func(seg *awsxray.Segment) map[string]any {
expectedResourceAttrs: func(*awsxray.Segment) map[string]any {
return nil
},
expectedRecord: xray.TelemetryRecord{
SegmentsReceivedCount: aws.Int64(1),
SegmentsRejectedCount: aws.Int64(1),
},
propsPerSpan: func(_ string, _ *testing.T, seg *awsxray.Segment) []perSpanProperties {
propsPerSpan: func(string, *testing.T, *awsxray.Segment) []perSpanProperties {
return nil
},
verification: func(testCase string,
actualSeg *awsxray.Segment,
expectedRs ptrace.ResourceSpans, actualTraces ptrace.Traces, err error) {
_ ptrace.ResourceSpans, _ ptrace.Traces, err error) {
assert.EqualError(t, err,
fmt.Sprintf(
"failed to parse out the database name in the \"sql.url\" field, rawUrl: %s",
Expand All @@ -856,19 +856,19 @@ func TestTranslation(t *testing.T) {
testCase: "TranslateJsonUnmarshallFailed",
expectedUnmarshallFailure: true,
samplePath: filepath.Join("../../../../internal/aws/xray", "testdata", "minCauseIsInvalid.txt"),
expectedResourceAttrs: func(seg *awsxray.Segment) map[string]any {
expectedResourceAttrs: func(*awsxray.Segment) map[string]any {
return nil
},
expectedRecord: xray.TelemetryRecord{
SegmentsReceivedCount: aws.Int64(0),
SegmentsRejectedCount: aws.Int64(0),
},
propsPerSpan: func(_ string, _ *testing.T, seg *awsxray.Segment) []perSpanProperties {
propsPerSpan: func(string, *testing.T, *awsxray.Segment) []perSpanProperties {
return nil
},
verification: func(testCase string,
actualSeg *awsxray.Segment,
expectedRs ptrace.ResourceSpans, actualTraces ptrace.Traces, err error) {
_ *awsxray.Segment,
_ ptrace.ResourceSpans, _ ptrace.Traces, err error) {
assert.EqualError(t, err,
fmt.Sprintf(
"the value assigned to the `cause` field does not appear to be a string: %v",
Expand All @@ -880,19 +880,19 @@ func TestTranslation(t *testing.T) {
{
testCase: "TranslateRootSegValidationFailed",
samplePath: filepath.Join("../../../../internal/aws/xray", "testdata", "segmentValidationFailed.txt"),
expectedResourceAttrs: func(seg *awsxray.Segment) map[string]any {
expectedResourceAttrs: func(*awsxray.Segment) map[string]any {
return nil
},
expectedRecord: xray.TelemetryRecord{
SegmentsReceivedCount: aws.Int64(1),
SegmentsRejectedCount: aws.Int64(1),
},
propsPerSpan: func(_ string, _ *testing.T, seg *awsxray.Segment) []perSpanProperties {
propsPerSpan: func(string, *testing.T, *awsxray.Segment) []perSpanProperties {
return nil
},
verification: func(testCase string,
actualSeg *awsxray.Segment,
expectedRs ptrace.ResourceSpans, actualTraces ptrace.Traces, err error) {
_ *awsxray.Segment,
_ ptrace.ResourceSpans, _ ptrace.Traces, err error) {
assert.EqualError(t, err, `segment "start_time" can not be nil`,
testCase+": translation should've failed")
},
Expand Down
8 changes: 4 additions & 4 deletions receiver/azuremonitorreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,18 @@ func (s *azureScraper) loadCredentials() (err error) {
func (s *azureScraper) scrape(ctx context.Context) (pmetric.Metrics, error) {

s.getResources(ctx)
resourcesIdsWithDefinitions := make(chan string)
resourcesIDsWithDefinitions := make(chan string)

go func() {
defer close(resourcesIdsWithDefinitions)
defer close(resourcesIDsWithDefinitions)
for resourceID := range s.resources {
s.getResourceMetricsDefinitions(ctx, resourceID)
resourcesIdsWithDefinitions <- resourceID
resourcesIDsWithDefinitions <- resourceID
}
}()

var wg sync.WaitGroup
for resourceID := range resourcesIdsWithDefinitions {
for resourceID := range resourcesIDsWithDefinitions {
wg.Add(1)
go func(resourceID string) {
defer wg.Done()
Expand Down
8 changes: 4 additions & 4 deletions receiver/azuremonitorreceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ type armClientMock struct {

func (acm *armClientMock) NewListPager(_ *armresources.ClientListOptions) *runtime.Pager[armresources.ClientListResponse] {
return runtime.NewPager(runtime.PagingHandler[armresources.ClientListResponse]{
More: func(page armresources.ClientListResponse) bool {
More: func(armresources.ClientListResponse) bool {
return acm.current < len(acm.pages)
},
Fetcher: func(ctx context.Context, page *armresources.ClientListResponse) (armresources.ClientListResponse, error) {
Fetcher: func(context.Context, *armresources.ClientListResponse) (armresources.ClientListResponse, error) {
currentPage := acm.pages[acm.current]
acm.current++
return currentPage, nil
Expand All @@ -168,10 +168,10 @@ type metricsDefinitionsClientMock struct {

func (mdcm *metricsDefinitionsClientMock) NewListPager(resourceURI string, _ *armmonitor.MetricDefinitionsClientListOptions) *runtime.Pager[armmonitor.MetricDefinitionsClientListResponse] {
return runtime.NewPager(runtime.PagingHandler[armmonitor.MetricDefinitionsClientListResponse]{
More: func(page armmonitor.MetricDefinitionsClientListResponse) bool {
More: func(armmonitor.MetricDefinitionsClientListResponse) bool {
return mdcm.current[resourceURI] < len(mdcm.pages[resourceURI])
},
Fetcher: func(ctx context.Context, page *armmonitor.MetricDefinitionsClientListResponse) (armmonitor.MetricDefinitionsClientListResponse, error) {
Fetcher: func(context.Context, *armmonitor.MetricDefinitionsClientListResponse) (armmonitor.MetricDefinitionsClientListResponse, error) {
currentPage := mdcm.pages[resourceURI][mdcm.current[resourceURI]]
mdcm.current[resourceURI]++
return currentPage, nil
Expand Down
Loading
Loading