Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-18.0] Fix #14414: resilient_server metrics name/prefix logic is inverted, leading to no metrics being recorded (#14415) #14527

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading