Skip to content

Commit

Permalink
region: add a metric to track bytes written to the wire per RPC call
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuna committed Jun 10, 2024
1 parent 67d205c commit 67e9a8a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions region/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ func (c *client) send(rpc hrpc.Call) (uint32, error) {
return id, err
}

rpcSize.WithLabelValues(c.Addr()).Observe(float64(uint32(len(b)) + cellblocksLen))
if cellblocks != nil {
bfs := append(net.Buffers{b}, cellblocks...)
_, err = bfs.WriteTo(c.conn)
Expand Down
6 changes: 3 additions & 3 deletions region/compressor.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ func resizeBufferCap(b []byte, capacity int) []byte {
return b
}

l := len(b)
b = append(b, make([]byte, capacity-l)...)
return b[:l]
b2 := make([]byte, capacity)
copy(b2, b)
return b2[:len(b)]
}

func (c *compressor) compressCellblocks(cbs net.Buffers, uncompressedLen uint32) []byte {
Expand Down
12 changes: 12 additions & 0 deletions region/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,16 @@ var (
},
[]string{"regionserver"},
)

rpcSize = promauto.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: "gohbase",
Name: "rpc_size_bytes",
Help: "Number of bytes sent per RPC call to HBase",
// >>> [1024*(4**i) for i in range(8)]
// [1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216]
Buckets: prometheus.ExponentialBuckets(1024, 4, 8),
},
[]string{"regionserver"},
)
)

0 comments on commit 67e9a8a

Please sign in to comment.