Skip to content

Commit

Permalink
[receiver/mongodbreceiver] Fix index access count error collection on…
Browse files Browse the repository at this point in the history
… a replica local database (#21116)

* remove local db collection for index access
  • Loading branch information
JonathanWamsley authored Apr 24, 2023
1 parent 1ff1aa4 commit 2f9961c
Show file tree
Hide file tree
Showing 6 changed files with 840 additions and 913 deletions.
16 changes: 16 additions & 0 deletions .chloggen/mongodb-fix-index-access-on-local-error.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Fixes scraper error `Unauthorized` by not calling index stats on an internal local MongoDB database.

# One or more tracking issues related to the change
issues: [21114]

# (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:
3 changes: 3 additions & 0 deletions receiver/mongodbreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ func (s *mongodbScraper) collectTopStats(ctx context.Context, now pcommon.Timest
}

func (s *mongodbScraper) collectIndexStats(ctx context.Context, now pcommon.Timestamp, databaseName string, collectionName string, errs *scrapererror.ScrapeErrors) {
if databaseName == "local" {
return
}
indexStats, err := s.client.IndexStats(ctx, databaseName, collectionName)
if err != nil {
errs.AddPartial(1, fmt.Errorf("failed to fetch index stats metrics: %w", err))
Expand Down
Loading

0 comments on commit 2f9961c

Please sign in to comment.