osbase/supervisor: implement Metrics API
This is a base building block for exporting per-DN/runnable status from
the supervisor into an external system. A sample implementation is
provided which can be used in simple debug facilities to inspect the
current supervision tree.
A follow-up change will use the same API to implement Prometheus
metrics.
Change-Id: I0d586b03a397a3ccf8dac2d8043b9dd2f319be4e
Reviewed-on: https://review.monogon.dev/c/monogon/+/3290
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/osbase/supervisor/supervisor_node.go b/osbase/supervisor/supervisor_node.go
index 8b31ad4..44e8c84 100644
--- a/osbase/supervisor/supervisor_node.go
+++ b/osbase/supervisor/supervisor_node.go
@@ -292,12 +292,14 @@
panic(fmt.Errorf("node %s signaled healthy", n))
}
n.state = NodeStateHealthy
+ n.sup.metrics.NotifyNodeState(n.dn(), n.state)
n.bo.Reset()
case SignalDone:
if n.state != NodeStateHealthy {
panic(fmt.Errorf("node %s signaled done", n))
}
n.state = NodeStateDone
+ n.sup.metrics.NotifyNodeState(n.dn(), n.state)
n.bo.Reset()
}
}