diff --git a/dm/dm/worker/source_worker.go b/dm/dm/worker/source_worker.go index f6605896610..83475c99da5 100644 --- a/dm/dm/worker/source_worker.go +++ b/dm/dm/worker/source_worker.go @@ -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) } } } diff --git a/dm/tests/metrics/run.sh b/dm/tests/metrics/run.sh index 9372497d489..9ecf992fc75 100755 --- a/dm/tests/metrics/run.sh +++ b/dm/tests/metrics/run.sh @@ -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[@]})" @@ -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;"