From 3cc2459779ca6a9643ad85a21b1214e27894cab4 Mon Sep 17 00:00:00 2001 From: Song Gao Date: Sun, 26 Sep 2021 18:06:28 +0800 Subject: [PATCH] add label (#314) Signed-off-by: yisaer --- internal/client/client.go | 3 ++- metrics/metrics.go | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/client/client.go b/internal/client/client.go index 392a2f84..416b5a57 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -358,7 +358,8 @@ func (c *RPCClient) updateTiKVSendReqHistogram(req *tikvrpc.Request, start time. if !ok { reqType := req.Type.String() storeID := strconv.FormatUint(req.Context.GetPeer().GetStoreId(), 10) - v = metrics.TiKVSendReqHistogram.WithLabelValues(reqType, storeID) + staleRead := strconv.FormatBool(req.StaleRead) + v = metrics.TiKVSendReqHistogram.WithLabelValues(reqType, storeID, staleRead) sendReqHistCache.Store(key, v) } diff --git a/metrics/metrics.go b/metrics/metrics.go index 3fc986a6..47191768 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -44,7 +44,7 @@ var ( TiKVTxnCmdHistogram *prometheus.HistogramVec TiKVBackoffHistogram *prometheus.HistogramVec TiKVSendReqHistogram *prometheus.HistogramVec - TiKVCoprocessorHistogram prometheus.Histogram + TiKVCoprocessorHistogram *prometheus.HistogramVec TiKVLockResolverCounter *prometheus.CounterVec TiKVRegionErrorCounter *prometheus.CounterVec TiKVTxnWriteKVCountHistogram prometheus.Histogram @@ -108,6 +108,7 @@ const ( LblAddress = "address" LblFromStore = "from_store" LblToStore = "to_store" + LblStaleRead = "stale_read" ) func initMetrics(namespace, subsystem string) { @@ -136,16 +137,16 @@ func initMetrics(namespace, subsystem string) { Name: "request_seconds", Help: "Bucketed histogram of sending request duration.", Buckets: prometheus.ExponentialBuckets(0.0005, 2, 29), // 0.5ms ~ 1.5days - }, []string{LblType, LblStore}) + }, []string{LblType, LblStore, LblStaleRead}) - TiKVCoprocessorHistogram = prometheus.NewHistogram( + TiKVCoprocessorHistogram = prometheus.NewHistogramVec( prometheus.HistogramOpts{ Namespace: namespace, Subsystem: subsystem, Name: "cop_duration_seconds", Help: "Run duration of a single coprocessor task, includes backoff time.", Buckets: prometheus.ExponentialBuckets(0.0005, 2, 29), // 0.5ms ~ 1.5days - }) + }, []string{LblStore, LblStaleRead}) TiKVLockResolverCounter = prometheus.NewCounterVec( prometheus.CounterOpts{