pkg/mesh: metric for reconcile attempts

This commit exposes a new Prometheus to track the number of
reconciliation attempts. This is important, as without this, the number
of errors it not too helpful. A more valuable statistic is the
proportion of reconciliations that result in an error.
This commit is contained in:
Lucas Servén Marín 2019-04-29 23:49:22 +02:00
parent cf6ded1ae3
commit 4cbc24128d
No known key found for this signature in database
GPG Key ID: 586FEAF680DA74AD
1 changed files with 10 additions and 3 deletions

View File

@ -153,9 +153,10 @@ type Mesh struct {
nodes map[string]*Node
mu sync.Mutex
errorCounter *prometheus.CounterVec
nodesGuage prometheus.Gauge
logger log.Logger
errorCounter *prometheus.CounterVec
nodesGuage prometheus.Gauge
reconcileCounter prometheus.Counter
logger log.Logger
}
// New returns a new Mesh instance.
@ -241,6 +242,10 @@ func New(backend Backend, encapsulate Encapsulate, granularity Granularity, host
Name: "kilo_nodes",
Help: "Number of in the mesh.",
}),
reconcileCounter: prometheus.NewCounter(prometheus.CounterOpts{
Name: "kilo_reconciles_total",
Help: "Number of reconciliation attempts.",
}),
logger: logger,
}, nil
}
@ -397,6 +402,7 @@ func (m *Mesh) handleLocal(n *Node) {
}
func (m *Mesh) applyTopology() {
m.reconcileCounter.Inc()
m.mu.Lock()
defer m.mu.Unlock()
// Ensure all unready nodes are removed.
@ -525,6 +531,7 @@ func (m *Mesh) RegisterMetrics(r prometheus.Registerer) {
r.MustRegister(
m.errorCounter,
m.nodesGuage,
m.reconcileCounter,
)
}