Skip to content

Commit

Permalink
source_worker(dm): peroidically update source metrics background (#4330)
Browse files Browse the repository at this point in the history
close #4281
  • Loading branch information
lance6716 authored Jan 14, 2022
1 parent 234cee7 commit d24f962
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dm/dm/worker/source_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ func (w *SourceWorker) Start() {
if w.l.Core().Enabled(zap.DebugLevel) {
w.l.Debug("runtime status", zap.String("status", w.GetUnitAndSourceStatusJSON("", sourceStatus)))
}

// periodically print the status and update metrics
w.Status("", sourceStatus)
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions dm/tests/metrics/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function run() {
inject_points=(
"github.com/pingcap/tiflow/dm/syncer/BlockDDLJob=return(1)"
"github.com/pingcap/tiflow/dm/syncer/ShowLagInLog=return(1)" # test lag metric >= 1 beacuse we inject BlockDDLJob(ddl) to sleep(1)
"github.com/pingcap/tiflow/dm/dm/worker/PrintStatusCheckSeconds=return(1)"
)
export GO_FAILPOINTS="$(join_string \; ${inject_points[@]})"

Expand Down Expand Up @@ -54,6 +55,11 @@ function run() {
check_metric $WORKER1_PORT 'dm_worker_task_state{source_id="mysql-replica-01",task="test",worker="worker1"}' 10 1 3
check_metric $WORKER2_PORT 'dm_worker_task_state{source_id="mysql-replica-02",task="test",worker="worker2"}' 10 1 3

# check dm_syncer_binlog_file is updated timely
run_sql_source1 "flush logs;"
check_metric $WORKER1_PORT 'dm_syncer_binlog_file{node="syncer",source_id="mysql-replica-01",task="test"}' 10 1 3
check_metric $WORKER1_PORT 'dm_syncer_binlog_file{node="master",source_id="mysql-replica-01",task="test"}' 10 1 3

# check ddl job lag
run_sql_source1 "alter table metrics.t1 add column new_col1 int;"
run_sql_source2 "alter table metrics.t2 add column new_col1 int;"
Expand Down

0 comments on commit d24f962

Please sign in to comment.