Skip to content

Commit

Permalink
Fix #14414: resilient_server metrics name/prefix logic is inverted, l…
Browse files Browse the repository at this point in the history
…eading to no metrics being recorded (#14415)

Signed-off-by: Jacques Grove <aquarapid@gmail.com>
Signed-off-by: deepthi <deepthi@planetscale.com>
Co-authored-by: deepthi <deepthi@planetscale.com>
  • Loading branch information
aquarapid and deepthi authored Nov 16, 2023
1 parent 5a93514 commit a40a89b
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 a40a89b

Please sign in to comment.