Skip to content

Commit

Permalink
Do not register healthcheck stats if they have already been registered.
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo J. Ortega U <[email protected]>
  • Loading branch information
ejortegau committed Oct 17, 2024
1 parent 37b690c commit bfbc3aa
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions go/vt/discovery/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ type HealthCheckImpl struct {
subscribers map[chan *TabletHealth]struct{}
// healthCheckDialSem is used to limit how many healthcheck connections can be opened to tablets at once.
healthCheckDialSem *semaphore.Weighted
// statsRegistered flags whether stats have already been registered by the healthcheck.
statsRegistered bool
}

// NewVTGateHealthCheckFilters returns healthcheck filters for vtgate.
Expand Down Expand Up @@ -861,28 +863,30 @@ func (hc *HealthCheckImpl) topologyWatcherChecksum() int64 {

// RegisterStats registers the connection counts stats
func (hc *HealthCheckImpl) RegisterStats() {
stats.NewGaugeDurationFunc(
"TopologyWatcherMaxRefreshLag",
"maximum time since the topology watcher refreshed a cell",
hc.topologyWatcherMaxRefreshLag,
)

stats.NewGaugeFunc(
"TopologyWatcherChecksum",
"crc32 checksum of the topology watcher state",
hc.topologyWatcherChecksum,
)

stats.NewGaugesFuncWithMultiLabels(
"HealthcheckConnections",
"the number of healthcheck connections registered",
[]string{"Keyspace", "ShardName", "TabletType"},
hc.servingConnStats)

stats.NewGaugeFunc(
"HealthcheckChecksum",
"crc32 checksum of the current healthcheck state",
hc.stateChecksum)
if !hc.statsRegistered {
stats.NewGaugeDurationFunc(
"TopologyWatcherMaxRefreshLag",
"maximum time since the topology watcher refreshed a cell",
hc.topologyWatcherMaxRefreshLag,
)

stats.NewGaugeFunc(
"TopologyWatcherChecksum",
"crc32 checksum of the topology watcher state",
hc.topologyWatcherChecksum,
)

stats.NewGaugesFuncWithMultiLabels(
"HealthcheckConnections",
"the number of healthcheck connections registered",
[]string{"Keyspace", "ShardName", "TabletType"},
hc.servingConnStats)

stats.NewGaugeFunc(
"HealthcheckChecksum",
"crc32 checksum of the current healthcheck state",
hc.stateChecksum)
}
}

// ServeHTTP is part of the http.Handler interface. It renders the current state of the discovery gateway tablet cache into json.
Expand Down

0 comments on commit bfbc3aa

Please sign in to comment.