feat: enhance EvoBGP with new command-line options for the evobgp-agent, including a watch command for periodic configuration updates. Update go.mod with additional dependencies and improve Docker Compose setup for new services, including NATS and various worker components.
This commit is contained in:
@@ -19,7 +19,7 @@ import (
|
||||
const namespace = "evobgp"
|
||||
|
||||
var (
|
||||
metricsMem atomic.Pointer[store.Memory]
|
||||
metricsStore atomic.Value // store.Backend
|
||||
registerCollectorOnce sync.Once
|
||||
)
|
||||
|
||||
@@ -122,15 +122,19 @@ func (c *memoryStoreCollector) Describe(ch chan<- *prometheus.Desc) {
|
||||
}
|
||||
|
||||
func (c *memoryStoreCollector) Collect(ch chan<- prometheus.Metric) {
|
||||
mem := metricsMem.Load()
|
||||
if mem == nil {
|
||||
v := metricsStore.Load()
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
maxN, sumN := mem.MaterializedPrefixStats()
|
||||
b, ok := v.(store.Backend)
|
||||
if !ok || b == nil {
|
||||
return
|
||||
}
|
||||
maxN, sumN := b.MaterializedPrefixStats()
|
||||
ch <- prometheus.MustNewConstMetric(c.prefixMaxDesc, prometheus.GaugeValue, float64(maxN))
|
||||
ch <- prometheus.MustNewConstMetric(c.prefixSumDesc, prometheus.GaugeValue, float64(sumN))
|
||||
ch <- prometheus.MustNewConstMetric(c.peersDesc, prometheus.GaugeValue, float64(mem.PeerCount()))
|
||||
for state, n := range mem.PeerSessionCountsByState() {
|
||||
ch <- prometheus.MustNewConstMetric(c.peersDesc, prometheus.GaugeValue, float64(b.PeerCount()))
|
||||
for state, n := range b.PeerSessionCountsByState() {
|
||||
if state == "" {
|
||||
state = "unknown"
|
||||
}
|
||||
@@ -138,15 +142,23 @@ func (c *memoryStoreCollector) Collect(ch chan<- prometheus.Metric) {
|
||||
}
|
||||
}
|
||||
|
||||
// RegisterStoreMetrics points Prometheus collectors at the given store (last call wins; safe for tests).
|
||||
// RegisterStoreBackend points Prometheus collectors at any store.Backend (last call wins; safe for tests).
|
||||
func RegisterStoreBackend(b store.Backend) {
|
||||
if b == nil {
|
||||
return
|
||||
}
|
||||
metricsStore.Store(b)
|
||||
registerCollectorOnce.Do(func() {
|
||||
prometheus.DefaultRegisterer.MustRegister(newMemoryStoreCollector())
|
||||
})
|
||||
}
|
||||
|
||||
// RegisterStoreMetrics is a deprecated alias for RegisterStoreBackend (memory-only callers).
|
||||
func RegisterStoreMetrics(mem *store.Memory) {
|
||||
if mem == nil {
|
||||
return
|
||||
}
|
||||
metricsMem.Store(mem)
|
||||
registerCollectorOnce.Do(func() {
|
||||
prometheus.DefaultRegisterer.MustRegister(newMemoryStoreCollector())
|
||||
})
|
||||
RegisterStoreBackend(mem)
|
||||
}
|
||||
|
||||
// SetBirdSessionMetrics updates gauges from an optional birdc scrape.
|
||||
|
||||
Reference in New Issue
Block a user