@@ -773,7 +773,7 @@ func (r *Manager) logSlowTableInfo(currentPDTime time.Time) {
773
773
}
774
774
775
775
// CollectMetrics collects metrics.
776
- func (r * Manager ) CollectMetrics () {
776
+ func (r * Manager ) CollectMetrics (currentPDTime time. Time ) {
777
777
cf := r .changefeedID
778
778
tableGauge .
779
779
WithLabelValues (cf .Namespace , cf .ID ).Set (float64 (r .spans .Len ()))
@@ -790,13 +790,12 @@ func (r *Manager) CollectMetrics() {
790
790
WithLabelValues (cf .Namespace , cf .ID ).Set (float64 (phyRTs ))
791
791
792
792
// Slow table latency metrics.
793
- phyCurrentTs := oracle .ExtractPhysical (table .Stats .CurrentTs )
794
793
for stage , checkpoint := range table .Stats .StageCheckpoints {
795
794
// Checkpoint ts
796
795
phyCkpTs := oracle .ExtractPhysical (checkpoint .CheckpointTs )
797
796
slowestTableStageCheckpointTsGaugeVec .
798
797
WithLabelValues (cf .Namespace , cf .ID , stage ).Set (float64 (phyCkpTs ))
799
- checkpointLag := float64 ( phyCurrentTs - phyCkpTs ) / 1e3
798
+ checkpointLag := currentPDTime . Sub ( oracle . GetTimeFromTS ( checkpoint . CheckpointTs )). Seconds ()
800
799
slowestTableStageCheckpointTsLagGaugeVec .
801
800
WithLabelValues (cf .Namespace , cf .ID , stage ).Set (checkpointLag )
802
801
slowestTableStageCheckpointTsLagHistogramVec .
@@ -805,7 +804,7 @@ func (r *Manager) CollectMetrics() {
805
804
phyRTs := oracle .ExtractPhysical (checkpoint .ResolvedTs )
806
805
slowestTableStageResolvedTsGaugeVec .
807
806
WithLabelValues (cf .Namespace , cf .ID , stage ).Set (float64 (phyRTs ))
808
- resolvedTsLag := float64 ( phyCurrentTs - phyRTs ) / 1e3
807
+ resolvedTsLag := currentPDTime . Sub ( oracle . GetTimeFromTS ( checkpoint . ResolvedTs )). Seconds ()
809
808
slowestTableStageResolvedTsLagGaugeVec .
810
809
WithLabelValues (cf .Namespace , cf .ID , stage ).Set (resolvedTsLag )
811
810
slowestTableStageResolvedTsLagHistogramVec .
@@ -816,7 +815,7 @@ func (r *Manager) CollectMetrics() {
816
815
phyBTs := oracle .ExtractPhysical (table .Stats .BarrierTs )
817
816
slowestTableStageResolvedTsGaugeVec .
818
817
WithLabelValues (cf .Namespace , cf .ID , stage ).Set (float64 (phyBTs ))
819
- barrierTsLag := float64 ( phyCurrentTs - phyBTs ) / 1e3
818
+ barrierTsLag := currentPDTime . Sub ( oracle . GetTimeFromTS ( table . Stats . BarrierTs )). Seconds ()
820
819
slowestTableStageResolvedTsLagGaugeVec .
821
820
WithLabelValues (cf .Namespace , cf .ID , stage ).Set (barrierTsLag )
822
821
slowestTableStageResolvedTsLagHistogramVec .
@@ -867,8 +866,7 @@ func (r *Manager) CollectMetrics() {
867
866
phyCkptTs := oracle .ExtractPhysical (pullerCkpt .ResolvedTs )
868
867
slowestTablePullerResolvedTs .WithLabelValues (cf .Namespace , cf .ID ).Set (float64 (phyCkptTs ))
869
868
870
- phyCurrentTs := oracle .ExtractPhysical (table .Stats .CurrentTs )
871
- lag := float64 (phyCurrentTs - phyCkptTs ) / 1e3
869
+ lag := currentPDTime .Sub (oracle .GetTimeFromTS (pullerCkpt .ResolvedTs )).Seconds ()
872
870
slowestTablePullerResolvedTsLag .WithLabelValues (cf .Namespace , cf .ID ).Set (lag )
873
871
}
874
872
}
0 commit comments