Skip to content

Commit

Permalink
[release-18.0] Fix #14414: resilient_server metrics name/prefix logic…
Browse files Browse the repository at this point in the history
… is inverted, leading to no metrics being recorded (#14415) (#14527)

Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
Co-authored-by: deepthi <[email protected]>
  • Loading branch information
vitess-bot[bot] and deepthi authored Nov 16, 2023
1 parent 374ef67 commit cdb0c36
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 2 additions & 4 deletions go/vt/srvtopo/resilient_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,9 @@ func NewResilientServer(ctx context.Context, base *topo.Server, counterPrefix st
log.Fatalf("srv_topo_cache_refresh must be less than or equal to srv_topo_cache_ttl")
}

var metric string
if counterPrefix == "" {
metric := ""
if counterPrefix != "" {
metric = counterPrefix + "Counts"
} else {
metric = ""
}
counts := stats.NewCountersWithSingleLabel(metric, "Resilient srvtopo server operations", "type")

Expand Down
2 changes: 1 addition & 1 deletion go/vt/srvtopo/resilient_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ func TestSrvKeyspaceListener(t *testing.T) {
srvTopoCacheRefresh = 1 * time.Second
}()

rs := NewResilientServer(ctx, ts, "TestGetSrvKeyspaceWatcher")
rs := NewResilientServer(ctx, ts, "TestGetSrvKeyspaceListener")

cancelCtx, cancelFunc := context.WithCancel(context.Background())
var callbackCount atomic.Int32
Expand Down
5 changes: 4 additions & 1 deletion go/vt/vttablet/tabletserver/vstreamer/testenv/testenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package testenv
import (
"context"
"fmt"
"math/rand"
"os"
"regexp"
"strings"
Expand Down Expand Up @@ -75,7 +76,9 @@ func Init(ctx context.Context) (*Env, error) {
if err := te.TopoServ.CreateShard(ctx, te.KeyspaceName, te.ShardName); err != nil {
panic(err)
}
te.SrvTopo = srvtopo.NewResilientServer(ctx, te.TopoServ, "TestTopo")
// Add a random suffix to metric name to avoid panic. Another option would have been to generate a random string.
suffix := rand.Int()
te.SrvTopo = srvtopo.NewResilientServer(ctx, te.TopoServ, "TestTopo"+fmt.Sprint(suffix))

cfg := vttest.Config{
Topology: &vttestpb.VTTestTopology{
Expand Down

0 comments on commit cdb0c36

Please sign in to comment.