From ba7ecd507021ca4f497dec3ba986b25d2af34b4e Mon Sep 17 00:00:00 2001 From: Salar Ali Mumtaz Date: Mon, 31 May 2021 11:14:18 -0400 Subject: [PATCH] Disable metrics collection for get and put functions --- rawkv/rawkv.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/rawkv/rawkv.go b/rawkv/rawkv.go index 23bc5248b..03b591457 100644 --- a/rawkv/rawkv.go +++ b/rawkv/rawkv.go @@ -91,8 +91,8 @@ func (c *Client) ClusterID() uint64 { // Get queries value with the key. When the key does not exist, it returns `nil, nil`. func (c *Client) Get(ctx context.Context, key []byte) ([]byte, error) { - start := time.Now() - defer func() { metrics.RawkvCmdHistogram.WithLabelValues("get").Observe(time.Since(start).Seconds()) }() + // start := time.Now() + // defer func() { metrics.RawkvCmdHistogram.WithLabelValues("get").Observe(time.Since(start).Seconds()) }() req := &rpc.Request{ Type: rpc.CmdRawGet, @@ -117,7 +117,6 @@ func (c *Client) Get(ctx context.Context, key []byte) ([]byte, error) { return cmdResp.Value, nil } - // Get queries value with the key. When the key does not exist, it returns `nil, nil`. func (c *Client) GetKeyTTL(ctx context.Context, key []byte) (*uint64, error) { start := time.Now() @@ -176,10 +175,10 @@ func (c *Client) BatchGet(ctx context.Context, keys [][]byte) ([][]byte, error) // Put stores a key-value pair to TiKV. func (c *Client) Put(ctx context.Context, key, value []byte, options ...PutOption) error { - start := time.Now() - defer func() { metrics.RawkvCmdHistogram.WithLabelValues("put").Observe(time.Since(start).Seconds()) }() - metrics.RawkvSizeHistogram.WithLabelValues("key").Observe(float64(len(key))) - metrics.RawkvSizeHistogram.WithLabelValues("value").Observe(float64(len(value))) + // start := time.Now() + // defer func() { metrics.RawkvCmdHistogram.WithLabelValues("put").Observe(time.Since(start).Seconds()) }() + // metrics.RawkvSizeHistogram.WithLabelValues("key").Observe(float64(len(key))) + // metrics.RawkvSizeHistogram.WithLabelValues("value").Observe(float64(len(value))) if len(value) == 0 { return errors.New("empty value is not supported") @@ -195,7 +194,7 @@ func (c *Client) Put(ctx context.Context, key, value []byte, options ...PutOptio RawPut: &kvrpcpb.RawPutRequest{ Key: key, Value: value, - Ttl: ttl, + Ttl: ttl, }, } resp, _, err := c.sendReq(ctx, key, req) @@ -677,7 +676,7 @@ func (c *Client) doBatchPut(bo *retry.Backoffer, batch batch, ttl uint64) error Type: rpc.CmdRawBatchPut, RawBatchPut: &kvrpcpb.RawBatchPutRequest{ Pairs: kvPair, - Ttl: ttl, + Ttl: ttl, }, }