Skip to content

Commit

Permalink
Add a metric to track the delay of the downstream
Browse files Browse the repository at this point in the history
  • Loading branch information
suzaku committed May 15, 2019
1 parent aabc1be commit 2451962
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drainer/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ var (
Help: "save checkpoint tso of drainer.",
})

checkpointDelayGauge = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: "binlog",
Subsystem: "drainer",
Name: "checkpoint_delay_seconds",
Help: "How much the downstream checkpoint lag behind",
})

executeHistogram = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "binlog",
Expand Down Expand Up @@ -123,6 +131,7 @@ func init() {
registry.MustRegister(ddlJobsCounter)
registry.MustRegister(errorCount)
registry.MustRegister(checkpointTSOGauge)
registry.MustRegister(checkpointDelayGauge)
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))
checkpointDelayGauge.Set(float64(delay) / 1e3)
}
}

Expand Down

0 comments on commit 2451962

Please sign in to comment.