Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drainer: Add a metric to track the delay of the downstream #594

Merged
merged 4 commits into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions drainer/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ var (
Help: "save checkpoint tso of drainer.",
})

checkpointDelayHistogram = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "binlog",
Subsystem: "drainer",
Name: "checkpoint_delay_seconds",
Help: "How much the downstream checkpoint lag behind",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 22),
})

executeHistogram = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "binlog",
Expand Down Expand Up @@ -123,6 +132,7 @@ func init() {
registry.MustRegister(ddlJobsCounter)
registry.MustRegister(errorCount)
registry.MustRegister(checkpointTSOGauge)
registry.MustRegister(checkpointDelayHistogram)
registry.MustRegister(eventCounter)
registry.MustRegister(executeHistogram)
registry.MustRegister(binlogReachDurationHistogram)
Expand Down
2 changes: 2 additions & 0 deletions drainer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ func (s *Syncer) handleSuccess(fakeBinlog chan *pb.Binlog, lastTS *int64) {
lastSaveTS = ts
eventCounter.WithLabelValues("savepoint").Add(1)
}
delay := oracle.GetPhysical(time.Now()) - oracle.ExtractPhysical(uint64(ts))
checkpointDelayHistogram.Observe(float64(delay) / 1e3)
}
}

Expand Down