From 1fee39f343954ca7501a6b8f25abd9f86eaf618b Mon Sep 17 00:00:00 2001 From: Benoit Sigoure Date: Mon, 10 Jun 2024 13:31:08 +0200 Subject: [PATCH 1/2] region: add a metric to track bytes written to the wire per RPC call --- region/client.go | 1 + region/compressor.go | 6 +++--- region/prometheus.go | 12 ++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/region/client.go b/region/client.go index 7336b66d..00297e1a 100644 --- a/region/client.go +++ b/region/client.go @@ -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) diff --git a/region/compressor.go b/region/compressor.go index 7a27d449..6e6cb10b 100644 --- a/region/compressor.go +++ b/region/compressor.go @@ -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 { diff --git a/region/prometheus.go b/region/prometheus.go index 4d0cbf81..56025df1 100644 --- a/region/prometheus.go +++ b/region/prometheus.go @@ -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"}, + ) ) From faec3bdfa39925b452453b80877efdd349f005ca Mon Sep 17 00:00:00 2001 From: Benoit Sigoure Date: Mon, 10 Jun 2024 13:40:30 +0200 Subject: [PATCH 2/2] go.mod: upgrade to go1.22 --- .github/workflows/ci.yml | 2 +- go.mod | 2 +- go.sum | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 92506968..01c8f71d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: [~1.18, ^1] + go: [~1.22, ^1] steps: - uses: actions/checkout@v2 diff --git a/go.mod b/go.mod index eb3a1aa8..268c967b 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/tsuna/gohbase -go 1.18 +go 1.22 require ( github.com/go-zookeeper/zk v1.0.3 diff --git a/go.sum b/go.sum index a4a1ba15..c206522c 100644 --- a/go.sum +++ b/go.sum @@ -120,6 +120,7 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=