Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions proxyd/consensus_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,13 +732,16 @@ func (cp *ConsensusPoller) setBackendState(be *Backend, peerCount uint64, inSync
func (cp *ConsensusPoller) getConsensusCandidates() map[*Backend]*backendState {

healthyPrimaries := cp.FilterCandidates(cp.backendGroup.Primaries())

RecordHealthyCandidates(cp.backendGroup, len(healthyPrimaries))

healthyFallbacks := cp.FilterCandidates(cp.backendGroup.Fallbacks())
RecordHealthyFallbackCandidates(cp.backendGroup, len(healthyFallbacks))

if len(healthyPrimaries) > 0 {
return healthyPrimaries
}

return cp.FilterCandidates(cp.backendGroup.Fallbacks())
return healthyFallbacks
}

// filterCandidates find out what backends are the candidates to be in the consensus group
Expand Down
12 changes: 12 additions & 0 deletions proxyd/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,14 @@ var (
"backend_group_name",
})

healthyFallbackCandidates = promauto.NewGaugeVec(prometheus.GaugeOpts{
Namespace: MetricsNamespace,
Name: "healthy_fallback_candidates",
Help: "Record the number of healthy fallback candidates",
}, []string{
"backend_group_name",
})

backendGroupFallbackBackend = promauto.NewGaugeVec(prometheus.GaugeOpts{
Namespace: MetricsNamespace,
Name: "backend_group_fallback_backenend",
Expand Down Expand Up @@ -605,6 +613,10 @@ func RecordHealthyCandidates(b *BackendGroup, candidates int) {
healthyPrimaryCandidates.WithLabelValues(b.Name).Set(float64(candidates))
}

func RecordHealthyFallbackCandidates(b *BackendGroup, candidates int) {
healthyFallbackCandidates.WithLabelValues(b.Name).Set(float64(candidates))
}

func RecordConsensusBackendPeerCount(b *Backend, peerCount uint64) {
consensusPeerCountBackend.WithLabelValues(b.Name).Set(float64(peerCount))
}
Expand Down