Skip to content

Commit

Permalink
Disable metrics collection for get and put functions
Browse files Browse the repository at this point in the history
  • Loading branch information
salarali committed May 31, 2021
1 parent d811a08 commit ba7ecd5
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions rawkv/rawkv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down Expand Up @@ -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")
Expand All @@ -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)
Expand Down Expand Up @@ -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,
},
}

Expand Down

0 comments on commit ba7ecd5

Please sign in to comment.