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.
CI / changes (push) Successful in 5s
CI / go (push) Successful in 1m40s
CI / openapi (push) Has been skipped
CI / bird2 (push) Successful in 17s

This commit is contained in:
Denozordec
2026-04-05 17:03:21 +07:00
parent bf52b21150
commit 6a55f72ab3
35 changed files with 4609 additions and 193 deletions
+23 -11
View File
@@ -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.