Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions downstreamadapter/dispatcher/basic_dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -669,11 +669,16 @@ func (d *BasicDispatcher) handleEvents(dispatcherEvents []DispatcherEvent, wakeC
zap.Int64("table", ddl.GetTableID()),
zap.Uint64("commitTs", event.GetCommitTs()),
zap.Uint64("seq", event.GetSeq()))
now := time.Now()
ddl.AddPostFlushFunc(func() {
if d.tableSchemaStore != nil {
d.tableSchemaStore.AddEvent(ddl)
}
wakeCallback()
cost := time.Since(now)
d.sharedInfo.metricHandleDDLHis.Observe(cost.Seconds())
log.Debug("dispatcher handle ddl event finish",
zap.Duration("cost", cost), zap.Any("ddl", ddl))
})
d.DealWithBlockEvent(ddl)
case commonEvent.TypeSyncPointEvent:
Expand Down
10 changes: 10 additions & 0 deletions downstreamadapter/dispatcher/basic_dispatcher_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"github.com/pingcap/ticdc/heartbeatpb"
"github.com/pingcap/ticdc/pkg/common"
"github.com/pingcap/ticdc/pkg/config"
"github.com/pingcap/ticdc/pkg/metrics"
"github.com/prometheus/client_golang/prometheus"
)

// SharedInfo contains all the shared configuration and resources
Expand Down Expand Up @@ -67,6 +69,10 @@ type SharedInfo struct {
// errCh is used to collect the errors that need to report to maintainer
// such as error of flush ddl events
errCh chan error

// metricHandleDDLHis records each DDL handling time duration,
// which includes the time of executing the DDL and waiting for the DDL to be resolved.
metricHandleDDLHis prometheus.Observer
}

// NewSharedInfo creates a new SharedInfo with the given parameters
Expand Down Expand Up @@ -99,6 +105,7 @@ func NewSharedInfo(
blockStatusesChan: blockStatusesChan,
blockExecutor: newBlockEventExecutor(),
errCh: errCh,
metricHandleDDLHis: metrics.HandleDDLHistogram.WithLabelValues(changefeedID.Keyspace(), changefeedID.Name()),
}

if txnAtomicity != nil {
Expand Down Expand Up @@ -263,4 +270,7 @@ func (s *SharedInfo) Close() {
if s.blockExecutor != nil {
s.blockExecutor.Close()
}
keyspace := s.changefeedID.Keyspace()
changefeedID := s.changefeedID.Name()
metrics.HandleDDLHistogram.DeleteLabelValues(keyspace, changefeedID)
}
88 changes: 86 additions & 2 deletions metrics/grafana/ticdc_new_arch.json
Original file line number Diff line number Diff line change
Expand Up @@ -25193,6 +25193,90 @@
"yaxis": {
"align": false
}
},
{
"cards": {
"cardPadding": 0,
"cardRound": 0
},
"color": {
"cardColor": "#FF9830",
"colorScale": "linear",
"colorScheme": "interpolateSpectral",
"exponent": 0.5,
"min": 0,
"mode": "spectrum"
},
"dataFormat": "tsbuckets",
"datasource": "${DS_TEST-CLUSTER}",
"description": "DDL handling duration distribution.",
"fieldConfig": {
"defaults": {},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 41
},
"heatmap": {},
"hideZeroBuckets": true,
"highlightCards": true,
"id": 62001,
"legend": {
"alignAsTable": true,
"avg": false,
"current": true,
"max": true,
"min": false,
"rightSide": true,
"show": true,
"sort": "current",
"sortDesc": true,
"total": false,
"values": true
},
"links": [],
"maxPerRow": 3,
"repeatDirection": "h",
"reverseYBuckets": false,
"targets": [
{
"exemplar": true,
"expr": "sum(rate(ticdc_ddl_handle_duration_bucket{k8s_cluster=\"$k8s_cluster\",tidb_cluster=\"$tidb_cluster\",namespace=~\"$namespace\",changefeed=~\"$changefeed\",instance=~\"$ticdc_instance\"}[1m])) by (le)",
"format": "heatmap",
"instant": false,
"interval": "",
"intervalFactor": 2,
"legendFormat": "{{le}}",
"refId": "A"
}
],
"title": "Handle DDL Duration",
"tooltip": {
"show": true,
"showHistogram": true
},
"tooltipDecimals": 1,
"type": "heatmap",
"xAxis": {
"show": true
},
"xBucketNumber": null,
"xBucketSize": null,
"yAxis": {
"decimals": 1,
"format": "s",
"logBase": 1,
"max": null,
"min": null,
"show": true,
"splitFactor": null
},
"yBucketBound": "upper",
"yBucketNumber": null,
"yBucketSize": null
}
],
"title": "DDL",
Expand Down Expand Up @@ -25514,5 +25598,5 @@
"timezone": "browser",
"title": "${DS_TEST-CLUSTER}-TiCDC-New-Arch",
"uid": "YiGL8hBZ0aac",
"version": 38
}
"version": 39
}
88 changes: 86 additions & 2 deletions metrics/nextgengrafana/ticdc_new_arch_next_gen.json
Original file line number Diff line number Diff line change
Expand Up @@ -25193,6 +25193,90 @@
"yaxis": {
"align": false
}
},
{
"cards": {
"cardPadding": 0,
"cardRound": 0
},
"color": {
"cardColor": "#FF9830",
"colorScale": "linear",
"colorScheme": "interpolateSpectral",
"exponent": 0.5,
"min": 0,
"mode": "spectrum"
},
"dataFormat": "tsbuckets",
"datasource": "${DS_TEST-CLUSTER}",
"description": "DDL handling duration distribution.",
"fieldConfig": {
"defaults": {},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 41
},
"heatmap": {},
"hideZeroBuckets": true,
"highlightCards": true,
"id": 62001,
"legend": {
"alignAsTable": true,
"avg": false,
"current": true,
"max": true,
"min": false,
"rightSide": true,
"show": true,
"sort": "current",
"sortDesc": true,
"total": false,
"values": true
},
"links": [],
"maxPerRow": 3,
"repeatDirection": "h",
"reverseYBuckets": false,
"targets": [
{
"exemplar": true,
"expr": "sum(rate(ticdc_ddl_handle_duration_bucket{k8s_cluster=\"$k8s_cluster\",sharedpool_id=\"$tidb_cluster\",keyspace_name=~\"$keyspace_name\",changefeed=~\"$changefeed\",instance=~\"$ticdc_instance\"}[1m])) by (le)",
"format": "heatmap",
"instant": false,
"interval": "",
"intervalFactor": 2,
"legendFormat": "{{le}}",
"refId": "A"
}
],
"title": "Handle DDL Duration",
"tooltip": {
"show": true,
"showHistogram": true
},
"tooltipDecimals": 1,
"type": "heatmap",
"xAxis": {
"show": true
},
"xBucketNumber": null,
"xBucketSize": null,
"yAxis": {
"decimals": 1,
"format": "s",
"logBase": 1,
"max": null,
"min": null,
"show": true,
"splitFactor": null
},
"yBucketBound": "upper",
"yBucketNumber": null,
"yBucketSize": null
}
],
"title": "DDL",
Expand Down Expand Up @@ -25514,5 +25598,5 @@
"timezone": "browser",
"title": "${DS_TEST-CLUSTER}-TiCDC-New-Arch",
"uid": "YiGL8hBZ0aac",
"version": 38
}
"version": 39
}
86 changes: 85 additions & 1 deletion metrics/nextgengrafana/ticdc_new_arch_with_keyspace_name.json
Original file line number Diff line number Diff line change
Expand Up @@ -9467,6 +9467,90 @@
"yaxis": {
"align": false
}
},
{
"cards": {
"cardPadding": 0,
"cardRound": 0
},
"color": {
"cardColor": "#FF9830",
"colorScale": "linear",
"colorScheme": "interpolateSpectral",
"exponent": 0.5,
"min": 0,
"mode": "spectrum"
},
"dataFormat": "tsbuckets",
"datasource": "${DS_TEST-CLUSTER}",
"description": "DDL handling duration distribution.",
"fieldConfig": {
"defaults": {},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 41
},
"heatmap": {},
"hideZeroBuckets": true,
"highlightCards": true,
"id": 62001,
"legend": {
"alignAsTable": true,
"avg": false,
"current": true,
"max": true,
"min": false,
"rightSide": true,
"show": true,
"sort": "current",
"sortDesc": true,
"total": false,
"values": true
},
"links": [],
"maxPerRow": 3,
"repeatDirection": "h",
"reverseYBuckets": false,
"targets": [
{
"exemplar": true,
"expr": "sum(rate(ticdc_ddl_handle_duration_bucket{k8s_cluster=\"$k8s_cluster\",tidb_cluster=\"$tidb_cluster\",keyspace_name=~\"$keyspace_name\",changefeed=~\"$changefeed\",instance=~\"$ticdc_instance\"}[1m])) by (le)",
"format": "heatmap",
"instant": false,
"interval": "",
"intervalFactor": 2,
"legendFormat": "{{le}}",
"refId": "A"
}
],
"title": "Handle DDL Duration",
"tooltip": {
"show": true,
"showHistogram": true
},
"tooltipDecimals": 1,
"type": "heatmap",
"xAxis": {
"show": true
},
"xBucketNumber": null,
"xBucketSize": null,
"yAxis": {
"decimals": 1,
"format": "s",
"logBase": 1,
"max": null,
"min": null,
"show": true,
"splitFactor": null
},
"yBucketBound": "upper",
"yBucketNumber": null,
"yBucketSize": null
}
],
"title": "DDL",
Expand Down Expand Up @@ -9788,5 +9872,5 @@
"timezone": "browser",
"title": "${DS_TEST-CLUSTER}-TiCDC-New-Arch-KeyspaceName",
"uid": "lGT5hED6vqTn",
"version": 38
"version": 39
}
14 changes: 13 additions & 1 deletion pkg/metrics/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,18 @@ import (
)

var (
// ExecDDLHistogram records the exexution time of a DDL.
// HandleDDLHistogram records the handling time of a DDL,
// which includes the time of executing the DDL and waiting for the DDL to be resolved.
HandleDDLHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: "ticdc",
Subsystem: "ddl",
Name: "handle_duration",
Help: "Bucketed histogram of handling time (s) of a ddl.",
Buckets: prometheus.ExponentialBuckets(0.01, 2, 18),
}, []string{getKeyspaceLabel(), "changefeed"})

// ExecDDLHistogram records the execution time of a DDL.
ExecDDLHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: "ticdc",
Expand Down Expand Up @@ -57,6 +68,7 @@ var (
)

func initDDLMetrics(registry *prometheus.Registry) {
registry.MustRegister(HandleDDLHistogram)
registry.MustRegister(ExecDDLHistogram)
registry.MustRegister(ExecDDLRunningGauge)
registry.MustRegister(ExecDDLBlockingGauge)
Expand Down