Skip to content

Commit

Permalink
register / remove metrics of dumpling
Browse files Browse the repository at this point in the history
  • Loading branch information
lance6716 committed Dec 31, 2020
1 parent 5f55bf3 commit a91adcb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dumpling/dumpling.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"strings"
"time"

"github.com/prometheus/client_golang/prometheus"

"github.com/pingcap/dm/dm/config"
"github.com/pingcap/dm/dm/pb"
"github.com/pingcap/dm/dm/unit"
Expand Down Expand Up @@ -219,6 +221,7 @@ func (m *Dumpling) constructArgs() (*export.Config, error) {
dumpConfig.CompleteInsert = true // always keep column name in `INSERT INTO` statements.
dumpConfig.Logger = m.logger.Logger
dumpConfig.NoViews = false
dumpConfig.Labels = prometheus.Labels{"task": cfg.Name}

if cfg.Threads > 0 {
dumpConfig.Threads = cfg.Threads
Expand Down
3 changes: 3 additions & 0 deletions dumpling/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package dumpling

import (
"github.com/pingcap/dumpling/v4/export"
"github.com/prometheus/client_golang/prometheus"

"github.com/pingcap/dm/pkg/metricsproxy"
Expand All @@ -33,8 +34,10 @@ var (
// RegisterMetrics registers metrics.
func RegisterMetrics(registry *prometheus.Registry) {
registry.MustRegister(dumplingExitWithErrorCounter)
export.RegisterMetrics(registry)
}

func (m *Dumpling) removeLabelValuesWithTaskInMetrics(task string) {
dumplingExitWithErrorCounter.DeleteAllAboutLabels(prometheus.Labels{"task": task})
export.RemoveLabelValuesWithTaskInMetrics(prometheus.Labels{"task": task})
}

0 comments on commit a91adcb

Please sign in to comment.