Skip to content

Commit

Permalink
metricbeat/module/mongodb: Improve logic
Browse files Browse the repository at this point in the history
  • Loading branch information
shmsr committed Jan 8, 2025
1 parent bc4feb6 commit fbabf0f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions metricbeat/module/mongodb/replstatus/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ func getOpTimestamp(collection *mongo.Collection) (uint32, uint32, error) {
// querying without any sort, it will return the first entry in natural order.
// When we sort in reverse natural order (i.e., $natural: -1), it will return
// the last entry in natural order.
//
// The queries use optimizations like FindOne() and SetProjection() to limit
// the amount of data that needs to be scanned and processed.
// Projection is used to limit the fields returned in the query results i.e., we
// only need the timestamp (ts) field. FindOne() is used to retrieve a single
// document from the collection (limit: 1).

var firstDoc struct {
Timestamp time.Time `bson:"ts"`
Expand Down

0 comments on commit fbabf0f

Please sign in to comment.