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

domain,metrics: add min start ts metric #32713

Open
wants to merge 3 commits into
base: master
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
8 changes: 7 additions & 1 deletion domain/infosync/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ const (
// InfoSessionTTL is the ETCD session's TTL in seconds.
InfoSessionTTL = 10 * 60
// ReportInterval is interval of infoSyncerKeeper reporting min startTS.
ReportInterval = 30 * time.Second
// 5 seconds for better accuracy.
ReportInterval = 5 * time.Second
// TopologyInformationPath means etcd path for storing topology info.
TopologyInformationPath = "/topology/tidb"
// TopologySessionTTL is ttl for topology, ant it's the ETCD session's TTL in seconds.
Expand Down Expand Up @@ -627,6 +628,11 @@ func (is *InfoSyncer) ReportMinStartTS(store kv.Storage) {
minStartTS = info.CurTxnStartTS
}
}
phyMinStartTs := oracle.ExtractPhysical(minStartTS)
metrics.DomainMinStartTsGauge.Set(float64(phyMinStartTs))
// Record min start ts lag in seconds.
phyNow := oracle.ExtractPhysical(currentVer.Ver)
metrics.DomainMinStartTsLagGauge.Set(float64(phyNow-phyMinStartTs) / 1e3)

is.minStartTS = minStartTS
err = is.storeMinStartTS(context.Background())
Expand Down
18 changes: 18 additions & 0 deletions metrics/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,22 @@ var (
Name: "handle_schema_validate",
Help: "Counter of handle schema validate",
}, []string{LblType})

// DomainMinStartTsGauge is the gauge that records the minmum start ts.
DomainMinStartTsGauge = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: "tidb",
Subsystem: "domain",
Name: "min_start_ts",
Help: "The minimum start ts of transactions in TiDB.",
})
// DomainMinStartTsLagGauge is the gauge that records the lag between
// the current PD tso and the minmum start ts.
DomainMinStartTsLagGauge = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: "tidb",
Subsystem: "domain",
Name: "min_start_ts_lag_secnods",
Help: "The lag between PD tso and the minimum start ts in seconds.",
})
)
2 changes: 2 additions & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ func RegisterMetrics() {
prometheus.MustRegister(TotalCopProcHistogram)
prometheus.MustRegister(TotalCopWaitHistogram)
prometheus.MustRegister(HandleSchemaValidate)
prometheus.MustRegister(DomainMinStartTsGauge)
prometheus.MustRegister(DomainMinStartTsLagGauge)
prometheus.MustRegister(MaxProcs)
prometheus.MustRegister(GOGC)
prometheus.MustRegister(ConnIdleDurationHistogram)
Expand Down