Skip to content

Commit

Permalink
vtorc: add tablets watched stats
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <[email protected]>
  • Loading branch information
timvaillancourt committed Mar 6, 2025
1 parent 5f80483 commit f4e5363
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions go/vt/vtorc/logic/tablet_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"google.golang.org/protobuf/encoding/prototext"
"google.golang.org/protobuf/proto"

"vitess.io/vitess/go/stats"
"vitess.io/vitess/go/vt/external/golib/sqlutils"
"vitess.io/vitess/go/vt/key"
"vitess.io/vitess/go/vt/log"
Expand All @@ -54,6 +55,13 @@ var (
// This is populated by parsing `--clusters_to_watch` flag.
shardsToWatch map[string][]*topodatapb.KeyRange

// tabletsWatchedByCell is a map of the number of tablets watched by cell.
tabletsWatchedByCell map[string]int64
statsTabletsWatched = stats.NewGaugesFuncWithMultiLabels("TabletsWatched", "Number of tablets watched by cell",
[]string{"cell"},
func() map[string]int64 { return tabletsWatchedByCell },
)

// ErrNoPrimaryTablet is a fixed error message.
ErrNoPrimaryTablet = errors.New("no primary tablet found")
)
Expand Down Expand Up @@ -168,6 +176,7 @@ func getAllTablets(ctx context.Context, cells []string) (tabletsByCell map[strin
failedCells = append(failedCells, cell)
} else {
tabletsByCell[cell] = tablets
tabletsWatchedByCell[cell] = int64(len(tablets))
}
return nil
})
Expand Down

0 comments on commit f4e5363

Please sign in to comment.