From b35f18d4ac42295159b2f5ebf4663ccff9797c03 Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Mon, 8 Jul 2024 12:57:01 +0800 Subject: [PATCH] metrics: use second as the unit of latency (#8367) ref tikv/pd#4399 Signed-off-by: Ryan Leung Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com> --- client/metrics.go | 2 +- client/tso_stream.go | 4 ++-- server/metrics.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/metrics.go b/client/metrics.go index e0b29fb8bcc..f3c47d7e787 100644 --- a/client/metrics.go +++ b/client/metrics.go @@ -105,7 +105,7 @@ func initMetrics(constLabels prometheus.Labels) { Subsystem: "request", Name: "tso_batch_send_latency", ConstLabels: constLabels, - Buckets: prometheus.ExponentialBuckets(1, 2, 34), // 1ns ~ 8s + Buckets: prometheus.ExponentialBuckets(0.0005, 2, 13), Help: "tso batch send latency", }) diff --git a/client/tso_stream.go b/client/tso_stream.go index 14b72bc697b..dd5b9422aae 100644 --- a/client/tso_stream.go +++ b/client/tso_stream.go @@ -139,7 +139,7 @@ func (s *pdTSOStream) processRequests( } return } - tsoBatchSendLatency.Observe(float64(time.Since(batchStartTime))) + tsoBatchSendLatency.Observe(time.Since(batchStartTime).Seconds()) resp, err := s.stream.Recv() if err != nil { if err == io.EOF { @@ -195,7 +195,7 @@ func (s *tsoTSOStream) processRequests( } return } - tsoBatchSendLatency.Observe(float64(time.Since(batchStartTime))) + tsoBatchSendLatency.Observe(time.Since(batchStartTime).Seconds()) resp, err := s.stream.Recv() if err != nil { if err == io.EOF { diff --git a/server/metrics.go b/server/metrics.go index 0935008a420..fdcc5b4be22 100644 --- a/server/metrics.go +++ b/server/metrics.go @@ -45,7 +45,7 @@ var ( Subsystem: "scheduler", Name: "region_heartbeat_latency_seconds", Help: "Bucketed histogram of latency (s) of receiving heartbeat.", - Buckets: prometheus.ExponentialBuckets(1, 2, 12), + Buckets: prometheus.ExponentialBuckets(0.0005, 2, 13), }, []string{"address", "store"}) metadataGauge = prometheus.NewGaugeVec(