Skip to content

Commit 0ef30ea

Browse files
author
leoppro
authored
metrics: delete metrics when close the puller (#963)
1 parent 89264a9 commit 0ef30ea

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cdc/puller/puller.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,17 @@ func (p *pullerImpl) Run(ctx context.Context) error {
139139
metricEventCounterKv := kvEventCounter.WithLabelValues(captureAddr, changefeedID, "kv")
140140
metricEventCounterResolved := kvEventCounter.WithLabelValues(captureAddr, changefeedID, "resolved")
141141
metricTxnCollectCounterKv := txnCollectCounter.WithLabelValues(captureAddr, changefeedID, tableName, "kv")
142-
metricTxnCollectCounterResolved := txnCollectCounter.WithLabelValues(captureAddr, changefeedID, tableName, "kv")
143-
142+
metricTxnCollectCounterResolved := txnCollectCounter.WithLabelValues(captureAddr, changefeedID, tableName, "resolved")
143+
defer func() {
144+
outputChanSizeGauge.DeleteLabelValues(captureAddr, changefeedID, tableName)
145+
eventChanSizeGauge.DeleteLabelValues(captureAddr, changefeedID, tableName)
146+
memBufferSizeGauge.DeleteLabelValues(captureAddr, changefeedID, tableName)
147+
pullerResolvedTsGauge.DeleteLabelValues(captureAddr, changefeedID, tableName)
148+
kvEventCounter.DeleteLabelValues(captureAddr, changefeedID, "kv")
149+
kvEventCounter.DeleteLabelValues(captureAddr, changefeedID, "resolved")
150+
txnCollectCounter.DeleteLabelValues(captureAddr, changefeedID, tableName, "kv")
151+
txnCollectCounter.DeleteLabelValues(captureAddr, changefeedID, tableName, "resolved")
152+
}()
144153
g.Go(func() error {
145154
for {
146155
select {

0 commit comments

Comments
 (0)