From af1c3d2fa17129fe34bbd362069eaa9caaf02afd Mon Sep 17 00:00:00 2001 From: MyonKeminta Date: Wed, 25 Sep 2024 17:29:20 +0800 Subject: [PATCH] Update estimated latency metric in tsoStream instead of tsoDispatcher Signed-off-by: MyonKeminta --- client/tso_dispatcher.go | 1 - client/tso_stream.go | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) 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..174b6c41c43 100644 --- a/client/tso_stream.go +++ b/client/tso_stream.go @@ -386,6 +386,8 @@ 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))) + // `filteredValue` is in microseconds. Update the metrics in seconds. + estimateTSOLatencyGauge.WithLabelValues(s.streamID).Set(filteredValue * 1e-6) } recvLoop: