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

Add tablet-tags/--init_tags stats #16695

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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 @@ -123,6 +123,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 @@ -142,6 +145,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 @@ -260,6 +264,11 @@ func BuildTabletFromInput(alias *topodatapb.TabletAlias, port, grpcPort int32, d
charset = collationEnv.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 @@ -272,7 +281,7 @@ func BuildTabletFromInput(alias *topodatapb.TabletAlias, port, grpcPort int32, d
KeyRange: keyRange,
Type: tabletType,
DbNameOverride: initDbNameOverride,
Tags: mergeTags(buildTags, initTags),
Tags: tags,
DefaultConnCollation: uint32(charset),
}, nil
}
Expand Down
Loading