Skip to content

Commit 7409f47

Browse files
committed
Add events_read_total metric
1 parent 777dc49 commit 7409f47

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

metrics/metrics.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ const metricNamespace = "percona_clustersync_mongodb"
1111

1212
// Counters.
1313
var (
14+
//nolint:gochecknoglobals
15+
eventsReadTotal = prometheus.NewCounter(prometheus.CounterOpts{
16+
Name: "events_read_total",
17+
Help: "Total number of events read from the source.",
18+
Namespace: metricNamespace,
19+
})
20+
1421
//nolint:gochecknoglobals
1522
eventsAppliedTotal = prometheus.NewCounter(prometheus.CounterOpts{
1623
Name: "events_applied_total",
@@ -144,6 +151,11 @@ func SetCopyInsertBatchDurationSeconds(dur time.Duration) {
144151
copyInsertBatchDurationSeconds.Set(float64(dur.Seconds()))
145152
}
146153

154+
// IncEventsRead increments the total number of events read counter.
155+
func IncEventsRead() {
156+
eventsReadTotal.Inc()
157+
}
158+
147159
// AddEventsApplied increments the total number of events applied counter.
148160
func AddEventsApplied(v int) {
149161
eventsAppliedTotal.Add(float64(v))

pcsm/repl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ func (r *Repl) run(opts *options.ChangeStreamOptionsBuilder) {
488488
}
489489

490490
r.eventsRead.Add(1)
491+
metrics.IncEventsRead()
491492

492493
if change.Namespace.Database == config.PCSMDatabase {
493494
if r.bulkWrite.Empty() {

0 commit comments

Comments
 (0)