-
Notifications
You must be signed in to change notification settings - Fork 288
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
metrics: add data flow metrics #2763
Merged
Merged
Changes from 15 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f3eab14
mounter, sink, pipeline: record total rows
overvenus b647b42
metrics: add data flow metrics
overvenus de6638d
Merge branch 'master' into metrics/dataflow
3AceShowHand 3227eaf
sink: fix compile
overvenus 5b99979
metrics: add puller total events
overvenus 8582344
metrics: correct legends
overvenus 85232c3
address comments
overvenus 3bfa423
metrics: display bottomk 10 tables and processors
overvenus c1fd777
address lints
overvenus 5e56272
Merge branch 'master' into metrics/dataflow
overvenus 6474837
metrics: adjust checkpoint derivative
overvenus b353d63
Merge branch 'metrics/dataflow' of https://github.com/overvenus/ticdc…
overvenus 2725de6
Merge branch 'master' into metrics/dataflow
overvenus 947a66b
Update cdc/sink/metrics.go
overvenus e5f7a60
Merge branch 'master' into metrics/dataflow
overvenus 24f99a0
Merge branch 'master' into metrics/dataflow
ti-chi-bot d160c6f
Merge branch 'master' into metrics/dataflow
ti-chi-bot eeebf8f
Merge branch 'master' into metrics/dataflow
ti-chi-bot 70aa404
Merge branch 'master' into metrics/dataflow
ti-chi-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ import ( | |
"github.com/pingcap/log" | ||
"github.com/pingcap/ticdc/cdc/model" | ||
"github.com/pingcap/ticdc/pkg/util" | ||
"github.com/prometheus/client_golang/prometheus" | ||
"go.uber.org/zap" | ||
) | ||
|
||
|
@@ -43,16 +44,26 @@ type Manager struct { | |
flushing int64 | ||
|
||
drawbackChan chan drawbackMsg | ||
|
||
captureAddr string | ||
changefeedID model.ChangeFeedID | ||
metricsTableSinkTotalRows prometheus.Counter | ||
} | ||
|
||
// NewManager creates a new Sink manager | ||
func NewManager(ctx context.Context, backendSink Sink, errCh chan error, checkpointTs model.Ts) *Manager { | ||
func NewManager( | ||
ctx context.Context, backendSink Sink, errCh chan error, checkpointTs model.Ts, | ||
captureAddr string, changefeedID model.ChangeFeedID, | ||
) *Manager { | ||
drawbackChan := make(chan drawbackMsg, 16) | ||
return &Manager{ | ||
backendSink: newBufferSink(ctx, backendSink, errCh, checkpointTs, drawbackChan), | ||
checkpointTs: checkpointTs, | ||
tableSinks: make(map[model.TableID]*tableSink), | ||
drawbackChan: drawbackChan, | ||
backendSink: newBufferSink(ctx, backendSink, errCh, checkpointTs, drawbackChan), | ||
checkpointTs: checkpointTs, | ||
tableSinks: make(map[model.TableID]*tableSink), | ||
drawbackChan: drawbackChan, | ||
captureAddr: captureAddr, | ||
changefeedID: changefeedID, | ||
metricsTableSinkTotalRows: tableSinkTotalRowsCountCounter.WithLabelValues(captureAddr, changefeedID), | ||
} | ||
} | ||
|
||
|
@@ -75,6 +86,7 @@ func (m *Manager) CreateTableSink(tableID model.TableID, checkpointTs model.Ts) | |
|
||
// Close closes the Sink manager and backend Sink, this method can be reentrantly called | ||
func (m *Manager) Close(ctx context.Context) error { | ||
tableSinkTotalRowsCountCounter.DeleteLabelValues(m.captureAddr, m.changefeedID) | ||
return m.backendSink.Close(ctx) | ||
} | ||
|
||
|
@@ -152,6 +164,7 @@ func (t *tableSink) Initialize(ctx context.Context, tableInfo []*model.SimpleTab | |
|
||
func (t *tableSink) EmitRowChangedEvents(ctx context.Context, rows ...*model.RowChangedEvent) error { | ||
t.buffer = append(t.buffer, rows...) | ||
t.manager.metricsTableSinkTotalRows.Add(float64(len(rows))) | ||
return nil | ||
} | ||
|
||
|
@@ -237,6 +250,13 @@ func (b *bufferSink) run(ctx context.Context, errCh chan error) { | |
metricFlushDuration := flushRowChangedDuration.WithLabelValues(advertiseAddr, changefeedID, "Flush") | ||
metricEmitRowDuration := flushRowChangedDuration.WithLabelValues(advertiseAddr, changefeedID, "EmitRow") | ||
metricBufferSize := bufferChanSizeGauge.WithLabelValues(advertiseAddr, changefeedID) | ||
metricTotalRows := bufferSinkTotalRowsCountCounter.WithLabelValues(advertiseAddr, changefeedID) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
defer func() { | ||
flushRowChangedDuration.DeleteLabelValues(advertiseAddr, changefeedID, "Flush") | ||
flushRowChangedDuration.DeleteLabelValues(advertiseAddr, changefeedID, "EmitRow") | ||
bufferChanSizeGauge.DeleteLabelValues(advertiseAddr, changefeedID) | ||
bufferSinkTotalRowsCountCounter.DeleteLabelValues(advertiseAddr, changefeedID) | ||
}() | ||
for { | ||
select { | ||
case <-ctx.Done(): | ||
|
@@ -257,6 +277,7 @@ func (b *bufferSink) run(ctx context.Context, errCh chan error) { | |
i := sort.Search(len(rows), func(i int) bool { | ||
return rows[i].CommitTs > resolvedTs | ||
}) | ||
metricTotalRows.Add(float64(i)) | ||
|
||
start := time.Now() | ||
err := b.Sink.EmitRowChangedEvents(ctx, rows[:i]...) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shall we delete this when closing the sink manager?