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

source_worker(dm): peroidically update source metrics background #4330

Merged
merged 3 commits into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
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