Skip to content

Commit

Permalink
Add tablet-tags/--init_tags stats
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <[email protected]>
  • Loading branch information
timvaillancourt committed Sep 2, 2024
1 parent 183309c commit bc308b6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion go/vt/vttablet/tabletmanager/tm_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit bc308b6

Please sign in to comment.