From bc308b6a508340096938a1e1370b4efd3e6ac0c4 Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Mon, 2 Sep 2024 20:14:01 +0200 Subject: [PATCH] Add tablet-tags/`--init_tags` stats Signed-off-by: Tim Vaillancourt --- go/vt/vttablet/tabletmanager/tm_init.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/go/vt/vttablet/tabletmanager/tm_init.go b/go/vt/vttablet/tabletmanager/tm_init.go index 16c4c2e4c1f..921f5a3132f 100644 --- a/go/vt/vttablet/tabletmanager/tm_init.go +++ b/go/vt/vttablet/tabletmanager/tm_init.go @@ -117,6 +117,9 @@ var ( // statsIsInSrvKeyspace is set to 1 (true), 0 (false) whether the tablet is in the serving keyspace statsIsInSrvKeyspace *stats.Gauge + // statsTabletTags is set to 1 (true) if a tablet tag exists. + statsTabletTags *stats.GaugesWithMultiLabels + statsKeyspace = stats.NewString("TabletKeyspace") statsShard = stats.NewString("TabletShard") statsKeyRangeStart = stats.NewString("TabletKeyRangeStart") @@ -136,6 +139,7 @@ func init() { statsTabletTypeCount = stats.NewCountersWithSingleLabel("TabletTypeCount", "Number of times the tablet changed to the labeled type", "type") statsBackupIsRunning = stats.NewGaugesWithMultiLabels("BackupIsRunning", "Whether a backup is running", []string{"mode"}) statsIsInSrvKeyspace = stats.NewGauge("IsInSrvKeyspace", "Whether the vttablet is in the serving keyspace (1 = true / 0 = false)") + statsTabletTags = stats.NewGaugesWithMultiLabels("TabletTags", "Tablet tags key/values", []string{"key", "value"}) } // TabletManager is the main class for the tablet manager. @@ -264,6 +268,11 @@ func BuildTabletFromInput(alias *topodatapb.TabletAlias, port, grpcPort int32, d charset = collations.Local().DefaultConnectionCharset() } + tags := mergeTags(buildTags, initTags) + for k, v := range tags { + statsTabletTags.Set([]string{k, v}, 1) + } + return &topodatapb.Tablet{ Alias: alias, Hostname: hostname, @@ -276,7 +285,7 @@ func BuildTabletFromInput(alias *topodatapb.TabletAlias, port, grpcPort int32, d KeyRange: keyRange, Type: tabletType, DbNameOverride: initDbNameOverride, - Tags: mergeTags(buildTags, initTags), + Tags: tags, DbServerVersion: dbServerVersion, DefaultConnCollation: uint32(charset), }, nil