@@ -286,7 +286,7 @@ type roundState struct {
286
286
func newRoundState (roundNumber uint64 , powerTable * PowerTable ) * roundState {
287
287
roundAttr := attrKeyRound .Int (int (roundNumber ))
288
288
return & roundState {
289
- converged : newConvergeState (),
289
+ converged : newConvergeState (roundAttr ),
290
290
prepared : newQuorumState (powerTable , attrPreparePhase , roundAttr ),
291
291
committed : newQuorumState (powerTable , attrCommitPhase , roundAttr ),
292
292
}
@@ -1323,6 +1323,10 @@ type convergeState struct {
1323
1323
senders map [ActorID ]struct {}
1324
1324
// Chains indexed by key.
1325
1325
values map [ECChainKey ]ConvergeValue
1326
+
1327
+ // sendersTotalPower is only used for metrics reporting
1328
+ sendersTotalPower int64
1329
+ attributes []attribute.KeyValue
1326
1330
}
1327
1331
1328
1332
// ConvergeValue is valid when the Chain is non-zero and Justification is non-nil
@@ -1341,10 +1345,11 @@ func (cv *ConvergeValue) IsValid() bool {
1341
1345
return ! cv .Chain .IsZero () && cv .Justification != nil
1342
1346
}
1343
1347
1344
- func newConvergeState () * convergeState {
1348
+ func newConvergeState (attributes ... attribute. KeyValue ) * convergeState {
1345
1349
return & convergeState {
1346
- senders : map [ActorID ]struct {}{},
1347
- values : map [ECChainKey ]ConvergeValue {},
1350
+ senders : map [ActorID ]struct {}{},
1351
+ values : map [ECChainKey ]ConvergeValue {},
1352
+ attributes : append ([]attribute.KeyValue {attrConvergePhase }, attributes ... ),
1348
1353
}
1349
1354
}
1350
1355
@@ -1379,6 +1384,11 @@ func (c *convergeState) Receive(sender ActorID, table *PowerTable, value *ECChai
1379
1384
}
1380
1385
c .senders [sender ] = struct {}{}
1381
1386
senderPower , _ := table .Get (sender )
1387
+ c .sendersTotalPower += senderPower
1388
+
1389
+ metrics .quorumParticipation .Record (context .Background (),
1390
+ float64 (c .sendersTotalPower )/ float64 (table .ScaledTotal ),
1391
+ metric .WithAttributes (c .attributes ... ))
1382
1392
1383
1393
key := value .Key ()
1384
1394
// Keep only the first justification and best ticket.
0 commit comments