Skip to content

Commit

Permalink
Add gauge metric that measures oplog entry staleness
Browse files Browse the repository at this point in the history
  • Loading branch information
torywheelwright committed Mar 27, 2024
1 parent 0867d6f commit fbc1127
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/oplog/tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ var (
ReportInterval: 1 * time.Minute,
},
}, []string{"database", "status"})

metricLastOplogEntryStaleness = promauto.NewGauge(prometheus.GaugeOpts{
Namespace: "otr",
Subsystem: "oplog",
Name: "last_entry_staleness",
Help: "Guage recording the difference between this server's clock and the timestamp on the last read oplog entry. This measure is confounded by the usual clock skew.",
})
)

func init() {
Expand Down Expand Up @@ -347,6 +354,7 @@ func (tailer *Tailer) unmarshalEntry(rawData bson.Raw) (timestamp *primitive.Tim

metricOplogEntriesBySize.WithLabelValues(database, status).Observe(messageLen)
metricMaxOplogEntryByMinute.Report(messageLen, database, status)
metricLastOplogEntryStaleness.Set(float64(uint32(time.Now().Unix()) - timestamp.T))
}()

if len(entries) > 0 {
Expand Down

0 comments on commit fbc1127

Please sign in to comment.