@@ -769,7 +769,7 @@ func (r *Manager) logSlowTableInfo(currentPDTime time.Time) {
769
769
}
770
770
771
771
// CollectMetrics collects metrics.
772
- func (r * Manager ) CollectMetrics () {
772
+ func (r * Manager ) CollectMetrics (currentPDTime time. Time ) {
773
773
cf := r .changefeedID
774
774
tableGauge .
775
775
WithLabelValues (cf .Namespace , cf .ID ).Set (float64 (r .spans .Len ()))
@@ -786,13 +786,12 @@ func (r *Manager) CollectMetrics() {
786
786
WithLabelValues (cf .Namespace , cf .ID ).Set (float64 (phyRTs ))
787
787
788
788
// Slow table latency metrics.
789
- phyCurrentTs := oracle .ExtractPhysical (table .Stats .CurrentTs )
790
789
for stage , checkpoint := range table .Stats .StageCheckpoints {
791
790
// Checkpoint ts
792
791
phyCkpTs := oracle .ExtractPhysical (checkpoint .CheckpointTs )
793
792
slowestTableStageCheckpointTsGaugeVec .
794
793
WithLabelValues (cf .Namespace , cf .ID , stage ).Set (float64 (phyCkpTs ))
795
- checkpointLag := float64 ( phyCurrentTs - phyCkpTs ) / 1e3
794
+ checkpointLag := currentPDTime . Sub ( oracle . GetTimeFromTS ( checkpoint . CheckpointTs )). Seconds ()
796
795
slowestTableStageCheckpointTsLagGaugeVec .
797
796
WithLabelValues (cf .Namespace , cf .ID , stage ).Set (checkpointLag )
798
797
slowestTableStageCheckpointTsLagHistogramVec .
@@ -801,7 +800,7 @@ func (r *Manager) CollectMetrics() {
801
800
phyRTs := oracle .ExtractPhysical (checkpoint .ResolvedTs )
802
801
slowestTableStageResolvedTsGaugeVec .
803
802
WithLabelValues (cf .Namespace , cf .ID , stage ).Set (float64 (phyRTs ))
804
- resolvedTsLag := float64 ( phyCurrentTs - phyRTs ) / 1e3
803
+ resolvedTsLag := currentPDTime . Sub ( oracle . GetTimeFromTS ( checkpoint . ResolvedTs )). Seconds ()
805
804
slowestTableStageResolvedTsLagGaugeVec .
806
805
WithLabelValues (cf .Namespace , cf .ID , stage ).Set (resolvedTsLag )
807
806
slowestTableStageResolvedTsLagHistogramVec .
@@ -812,7 +811,7 @@ func (r *Manager) CollectMetrics() {
812
811
phyBTs := oracle .ExtractPhysical (table .Stats .BarrierTs )
813
812
slowestTableStageResolvedTsGaugeVec .
814
813
WithLabelValues (cf .Namespace , cf .ID , stage ).Set (float64 (phyBTs ))
815
- barrierTsLag := float64 ( phyCurrentTs - phyBTs ) / 1e3
814
+ barrierTsLag := currentPDTime . Sub ( oracle . GetTimeFromTS ( table . Stats . BarrierTs )). Seconds ()
816
815
slowestTableStageResolvedTsLagGaugeVec .
817
816
WithLabelValues (cf .Namespace , cf .ID , stage ).Set (barrierTsLag )
818
817
slowestTableStageResolvedTsLagHistogramVec .
@@ -863,8 +862,7 @@ func (r *Manager) CollectMetrics() {
863
862
phyCkptTs := oracle .ExtractPhysical (pullerCkpt .ResolvedTs )
864
863
slowestTablePullerResolvedTs .WithLabelValues (cf .Namespace , cf .ID ).Set (float64 (phyCkptTs ))
865
864
866
- phyCurrentTs := oracle .ExtractPhysical (table .Stats .CurrentTs )
867
- lag := float64 (phyCurrentTs - phyCkptTs ) / 1e3
865
+ lag := currentPDTime .Sub (oracle .GetTimeFromTS (pullerCkpt .ResolvedTs )).Seconds ()
868
866
slowestTablePullerResolvedTsLag .WithLabelValues (cf .Namespace , cf .ID ).Set (lag )
869
867
}
870
868
}
0 commit comments