Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions exporter/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func unique(slice []string) []string {
}

func checkNamespacesForViews(ctx context.Context, client *mongo.Client, collections []string) ([]string, error) {
onlyCollectionsNamespaces, err := listAllCollections(ctx, client, nil, nil, true)
onlyCollectionsNamespaces, err := listAllCollections(ctx, client, collections, nil, true)
if err != nil {
return nil, err
}
Expand All @@ -183,7 +183,7 @@ func checkNamespacesForViews(ctx context.Context, client *mongo.Client, collecti
}

if _, ok := namespaces[collection]; !ok {
return nil, errors.Errorf("namespace %s is a view and cannot be used for collstats/indexstats", collection)
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's log that we are skipping this collection

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah good idea

}

filteredCollections = append(filteredCollections, collection)
Expand Down
5 changes: 3 additions & 2 deletions exporter/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ func TestCheckNamespacesForViews(t *testing.T) {
defer cleanupDB(ctx, client)

t.Run("Views in provided collection list (should fail)", func(t *testing.T) {
_, err := checkNamespacesForViews(ctx, client, []string{"testdb01.col01", "testdb01.system.views", "testdb01.view01"})
assert.EqualError(t, err, "namespace testdb01.view01 is a view and cannot be used for collstats/indexstats")
filtered, err := checkNamespacesForViews(ctx, client, []string{"testdb01.col01", "testdb01.system.views", "testdb01.view01"})
assert.NoError(t, err)
assert.Equal(t, []string{"testdb01.col01", "testdb01.system.views"}, filtered)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to also update the test name. also, testdb01.view01 is a view, so we should only expect testdb01.col01 in this list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. very good, I agree with you

})

t.Run("No Views in provided collection list", func(t *testing.T) {
Expand Down
Loading