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

owner, metrics(ticdc): fix metrics (#10459) #10565

Open
wants to merge 1 commit into
base: release-6.1
Choose a base branch
from
Open
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
85 changes: 85 additions & 0 deletions cdc/owner/changefeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,44 @@
metricsChangefeedResolvedTsLagGauge prometheus.Gauge
metricsChangefeedTickDuration prometheus.Observer

<<<<<<< HEAD

Check failure on line 112 in cdc/owner/changefeed.go

View workflow job for this annotation

GitHub Actions / Arm Build (ARM64)

syntax error: unexpected <<, expecting field name or embedded type

Check failure on line 112 in cdc/owner/changefeed.go

View workflow job for this annotation

GitHub Actions / Mac OS Build

syntax error: unexpected <<, expecting field name or embedded type
newDDLPuller func(ctx cdcContext.Context, upStream *upstream.Upstream, startTs uint64) (DDLPuller, error)
newSink func() DDLSink
newScheduler func(ctx cdcContext.Context, startTs uint64) (scheduler.Scheduler, error)
=======

Check failure on line 116 in cdc/owner/changefeed.go

View workflow job for this annotation

GitHub Actions / Arm Build (ARM64)

syntax error: unexpected ==, expecting field name or embedded type

Check failure on line 116 in cdc/owner/changefeed.go

View workflow job for this annotation

GitHub Actions / Mac OS Build

syntax error: unexpected ==, expecting field name or embedded type
metricsChangefeedBarrierTsGauge prometheus.Gauge
metricsChangefeedTickDuration prometheus.Observer

metricsChangefeedCreateTimeGuage prometheus.Gauge
metricsChangefeedRestartTimeGauge prometheus.Gauge

downstreamObserver observer.Observer
observerLastTick *atomic.Time

newDDLPuller func(ctx context.Context,
up *upstream.Upstream,
startTs uint64,
changefeed model.ChangeFeedID,
schemaStorage entry.SchemaStorage,
filter filter.Filter,
) puller.DDLPuller

newSink func(
changefeedID model.ChangeFeedID, info *model.ChangeFeedInfo,
reportError func(err error), reportWarning func(err error),
) DDLSink

newScheduler func(
ctx cdcContext.Context, up *upstream.Upstream, epoch uint64, cfg *config.SchedulerConfig, redoMetaManager redo.MetaManager,
) (scheduler.Scheduler, error)

newDownstreamObserver func(
ctx context.Context,
changefeedID model.ChangeFeedID,
sinkURIStr string, replCfg *config.ReplicaConfig,
opts ...observer.NewObserverOption,
) (observer.Observer, error)
>>>>>>> d3d06e5388 (owner, metrics(ticdc): fix metrics (#10459))

Check failure on line 149 in cdc/owner/changefeed.go

View workflow job for this annotation

GitHub Actions / Arm Build (ARM64)

syntax error: unexpected >>, expecting field name or embedded type

Check failure on line 149 in cdc/owner/changefeed.go

View workflow job for this annotation

GitHub Actions / Arm Build (ARM64)

invalid character U+0023 '#'

Check failure on line 149 in cdc/owner/changefeed.go

View workflow job for this annotation

GitHub Actions / Mac OS Build

syntax error: unexpected >>, expecting field name or embedded type

Check failure on line 149 in cdc/owner/changefeed.go

View workflow job for this annotation

GitHub Actions / Mac OS Build

invalid character U+0023 '#'

lastDDLTs uint64 // Timestamp of the last executed DDL. Only used for tests.
}
Expand Down Expand Up @@ -470,9 +505,49 @@
zap.String("namespace", c.id.Namespace),
zap.String("changefeed", c.id.ID))

<<<<<<< HEAD

Check failure on line 508 in cdc/owner/changefeed.go

View workflow job for this annotation

GitHub Actions / Arm Build (ARM64)

syntax error: unexpected <<, expecting }

Check failure on line 508 in cdc/owner/changefeed.go

View workflow job for this annotation

GitHub Actions / Mac OS Build

syntax error: unexpected <<, expecting }
// init metrics
c.metricsChangefeedBarrierTsGauge = changefeedBarrierTsGauge.
WithLabelValues(c.id.Namespace, c.id.ID)
=======
c.ddlManager = newDDLManager(
c.id,
ddlStartTs,
c.latestStatus.CheckpointTs,
c.ddlSink,
c.ddlPuller,
c.schema,
c.redoDDLMgr,
c.redoMetaMgr,
util.GetOrZero(c.latestInfo.Config.BDRMode))

// create scheduler
cfg := *c.cfg
cfg.ChangefeedSettings = c.latestInfo.Config.Scheduler
epoch := c.latestInfo.Epoch
c.scheduler, err = c.newScheduler(ctx, c.upstream, epoch, &cfg, c.redoMetaMgr)
if err != nil {
return errors.Trace(err)
}

c.initMetrics()

c.initialized = true
c.metricsChangefeedCreateTimeGuage.Set(float64(oracle.GetPhysical(c.latestInfo.CreateTime)))
c.metricsChangefeedRestartTimeGauge.Set(float64(oracle.GetPhysical(time.Now())))
log.Info("changefeed initialized",
zap.String("namespace", c.id.Namespace),
zap.String("changefeed", c.id.ID),
zap.Uint64("changefeedEpoch", epoch),
zap.Uint64("checkpointTs", checkpointTs),
zap.Uint64("resolvedTs", c.resolvedTs),
zap.String("info", c.latestInfo.String()))

return nil
}

func (c *changefeed) initMetrics() {
>>>>>>> d3d06e5388 (owner, metrics(ticdc): fix metrics (#10459))

Check failure on line 550 in cdc/owner/changefeed.go

View workflow job for this annotation

GitHub Actions / Arm Build (ARM64)

syntax error: unexpected >>, expecting }

Check failure on line 550 in cdc/owner/changefeed.go

View workflow job for this annotation

GitHub Actions / Arm Build (ARM64)

invalid character U+0023 '#'

Check failure on line 550 in cdc/owner/changefeed.go

View workflow job for this annotation

GitHub Actions / Mac OS Build

syntax error: unexpected >>, expecting }

Check failure on line 550 in cdc/owner/changefeed.go

View workflow job for this annotation

GitHub Actions / Mac OS Build

invalid character U+0023 '#'
c.metricsChangefeedCheckpointTsGauge = changefeedCheckpointTsGauge.
WithLabelValues(c.id.Namespace, c.id.ID)
c.metricsChangefeedCheckpointTsLagGauge = changefeedCheckpointTsLagGauge.
Expand All @@ -484,6 +559,7 @@
c.metricsChangefeedTickDuration = changefeedTickDuration.
WithLabelValues(c.id.Namespace, c.id.ID)

<<<<<<< HEAD
// create scheduler
c.scheduler, err = c.newScheduler(ctx, checkpointTs)
if err != nil {
Expand All @@ -499,10 +575,17 @@

c.initialized = true
return nil
=======
c.metricsChangefeedCreateTimeGuage = changefeedStartTimeGauge.
WithLabelValues(c.id.Namespace, c.id.ID, "create")
c.metricsChangefeedRestartTimeGauge = changefeedStartTimeGauge.
WithLabelValues(c.id.Namespace, c.id.ID, "restart")
>>>>>>> d3d06e5388 (owner, metrics(ticdc): fix metrics (#10459))

Check failure on line 583 in cdc/owner/changefeed.go

View workflow job for this annotation

GitHub Actions / Arm Build (ARM64)

invalid character U+0023 '#'

Check failure on line 583 in cdc/owner/changefeed.go

View workflow job for this annotation

GitHub Actions / Mac OS Build

invalid character U+0023 '#'
}

// releaseResources is idempotent.
func (c *changefeed) releaseResources(ctx cdcContext.Context) {
c.cleanupMetrics()
if c.isReleased {
return
}
Expand Down Expand Up @@ -555,6 +638,8 @@

if c.isRemoved {
changefeedStatusGauge.DeleteLabelValues(c.id.Namespace, c.id.ID)
changefeedCheckpointTsGauge.DeleteLabelValues(c.id.Namespace, c.id.ID, "create")
changefeedCheckpointTsLagGauge.DeleteLabelValues(c.id.Namespace, c.id.ID, "restart")
}
c.isReleased = true
c.initialized = false
Expand Down
8 changes: 8 additions & 0 deletions cdc/owner/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ var (
Help: "Bucketed histogram of owner close changefeed reactor time (s).",
Buckets: prometheus.ExponentialBuckets(0.01 /* 10 ms */, 2, 18),
})
changefeedStartTimeGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "ticdc",
Subsystem: "owner",
Name: "changefeed_start_time",
Help: "The start time of changefeeds",
}, []string{"namespace", "changefeed", "type"})
)

const (
Expand All @@ -119,4 +126,5 @@ func InitMetrics(registry *prometheus.Registry) {
registry.MustRegister(changefeedStatusGauge)
registry.MustRegister(changefeedTickDuration)
registry.MustRegister(changefeedCloseDuration)
registry.MustRegister(changefeedStartTimeGauge)
}
Loading
Loading