Skip to content

Commit

Permalink
fixed small comments on PR
Browse files Browse the repository at this point in the history
  • Loading branch information
chan-tim-sumo committed Jan 27, 2025
1 parent 2f06b9e commit 4531088
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
11 changes: 10 additions & 1 deletion receiver/mongodbreceiver/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,16 @@ func (fc *fakeClient) RunCommand(ctx context.Context, db string, command bson.M)
if args.Get(0) == nil {
return nil, args.Error(1)
}
return args.Get(0).(bson.M), args.Error(1)

result, ok := args.Get(0).(bson.M)
if !ok {
err := errors.New("mock returned invalid type")
zap.L().Error("type assertion failed",
zap.String("expected", "bson.M"))
return nil, err
}

return result, args.Error(1)
}

func TestListDatabaseNames(t *testing.T) {
Expand Down
6 changes: 1 addition & 5 deletions receiver/mongodbreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func (s *mongodbScraper) findSecondaryHosts(ctx context.Context) ([]string, erro

members, ok := result["members"].(primitive.A)
if !ok {
return nil, fmt.Errorf("invalid members format")
return nil, fmt.Errorf("invalid members format: expected type primitive.A but got %T, value: %v", result["members"], result["members"])
}

var hosts []string
Expand Down Expand Up @@ -333,9 +333,5 @@ func (s *mongodbScraper) findSecondaryHosts(ctx context.Context) ([]string, erro
}
}

if len(hosts) == 0 {
s.logger.Warn("No secondary hosts found in replica set")
}

return hosts, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ resourceMetrics:
startTimeUnixNano: "1682363202250964000"
timeUnixNano: "1682363222253814000"
isMonotonic: true
unit: '{operations}'
unit: '{operations}'
- description: The total time spent performing operations.
name: mongodb.operation.time
sum:
Expand Down

0 comments on commit 4531088

Please sign in to comment.