diff --git a/client/tso_dispatcher.go b/client/tso_dispatcher.go index 009b017aa4d..7febf194f3c 100644 --- a/client/tso_dispatcher.go +++ b/client/tso_dispatcher.go @@ -353,7 +353,6 @@ tsoBatchLoop: // continue collecting. if td.isConcurrentRPCEnabled() { estimatedLatency := stream.EstimatedRPCLatency() - estimateTSOLatencyGauge.WithLabelValues(streamURL).Set(estimatedLatency.Seconds()) goalBatchTime := estimatedLatency / time.Duration(td.rpcConcurrency) failpoint.Inject("tsoDispatcherConcurrentModeAssertDelayDuration", func(val failpoint.Value) { diff --git a/client/tso_stream.go b/client/tso_stream.go index b8118b04468..142ad71c6b9 100644 --- a/client/tso_stream.go +++ b/client/tso_stream.go @@ -385,7 +385,10 @@ func (s *tsoStream) recvLoop(ctx context.Context) { } currentSample := math.Log(float64(latency.Microseconds())) filteredValue := filter.update(sampleTime, currentSample) - s.estimatedLatencyMicros.Store(uint64(math.Exp(filteredValue))) + micros := math.Exp(filteredValue) + s.estimatedLatencyMicros.Store(uint64(micros)) + // Update the metrics in seconds. + estimateTSOLatencyGauge.WithLabelValues(s.streamID).Set(micros * 1e-6) } recvLoop: