Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
nslaughter committed Feb 15, 2024
2 parents 93e588f + 65948d4 commit 4379aac
Show file tree
Hide file tree
Showing 50 changed files with 188 additions and 338 deletions.
27 changes: 27 additions & 0 deletions .chloggen/featuregate-mongo-beta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: receiver/mongodb

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Bump receiver.mongodb.removeDatabaseAttr feature gate to beta

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [31212]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
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

0 comments on commit 4379aac

Please sign in to comment.