@@ -243,10 +243,10 @@ func newInstance(
243
243
if input .IsZero () {
244
244
return nil , fmt .Errorf ("input is empty" )
245
245
}
246
+
246
247
metrics .phaseCounter .Add (context .TODO (), 1 , metric .WithAttributes (attrInitialPhase ))
247
248
metrics .currentInstance .Record (context .TODO (), int64 (instanceID ))
248
249
metrics .currentPhase .Record (context .TODO (), int64 (INITIAL_PHASE ))
249
- metrics .currentRound .Record (context .TODO (), 0 )
250
250
251
251
return & instance {
252
252
participant : participant ,
@@ -500,6 +500,14 @@ func (i *instance) tryCurrentPhase() error {
500
500
}
501
501
}
502
502
503
+ func (i * instance ) reportPhaseMetrics () {
504
+ attr := metric .WithAttributes (attrPhase [i .current .Phase ])
505
+
506
+ metrics .phaseCounter .Add (context .TODO (), 1 , attr )
507
+ metrics .currentPhase .Record (context .TODO (), int64 (i .current .Phase ))
508
+ metrics .proposalLength .Record (context .TODO (), int64 (i .proposal .Len ()- 1 ), attr )
509
+ }
510
+
503
511
// Sends this node's QUALITY message and begins the QUALITY phase.
504
512
func (i * instance ) beginQuality () error {
505
513
if i .current .Phase != INITIAL_PHASE {
@@ -511,8 +519,7 @@ func (i *instance) beginQuality() error {
511
519
i .phaseTimeout = i .alarmAfterSynchronyWithMulti (i .participant .qualityDeltaMulti )
512
520
i .resetRebroadcastParams ()
513
521
i .broadcast (i .current .Round , QUALITY_PHASE , i .proposal , false , nil )
514
- metrics .phaseCounter .Add (context .TODO (), 1 , metric .WithAttributes (attrQualityPhase ))
515
- metrics .currentPhase .Record (context .TODO (), int64 (QUALITY_PHASE ))
522
+ i .reportPhaseMetrics ()
516
523
return nil
517
524
}
518
525
@@ -572,8 +579,7 @@ func (i *instance) beginConverge(justification *Justification) {
572
579
i .getRound (i .current .Round ).converged .SetSelfValue (i .proposal , justification )
573
580
574
581
i .broadcast (i .current .Round , CONVERGE_PHASE , i .proposal , true , justification )
575
- metrics .phaseCounter .Add (context .TODO (), 1 , metric .WithAttributes (attrConvergePhase ))
576
- metrics .currentPhase .Record (context .TODO (), int64 (CONVERGE_PHASE ))
582
+ i .reportPhaseMetrics ()
577
583
}
578
584
579
585
// Attempts to end the CONVERGE phase and begin PREPARE based on current state.
@@ -630,8 +636,7 @@ func (i *instance) beginPrepare(justification *Justification) {
630
636
i .resetRebroadcastParams ()
631
637
632
638
i .broadcast (i .current .Round , PREPARE_PHASE , i .value , false , justification )
633
- metrics .phaseCounter .Add (context .TODO (), 1 , metric .WithAttributes (attrPreparePhase ))
634
- metrics .currentPhase .Record (context .TODO (), int64 (PREPARE_PHASE ))
639
+ i .reportPhaseMetrics ()
635
640
}
636
641
637
642
// Attempts to end the PREPARE phase and begin COMMIT based on current state.
@@ -681,8 +686,7 @@ func (i *instance) beginCommit() {
681
686
}
682
687
683
688
i .broadcast (i .current .Round , COMMIT_PHASE , i .value , false , justification )
684
- metrics .phaseCounter .Add (context .TODO (), 1 , metric .WithAttributes (attrCommitPhase ))
685
- metrics .currentPhase .Record (context .TODO (), int64 (COMMIT_PHASE ))
689
+ i .reportPhaseMetrics ()
686
690
}
687
691
688
692
func (i * instance ) tryCommit (round uint64 ) error {
@@ -755,8 +759,7 @@ func (i *instance) beginDecide(round uint64) {
755
759
// Since each node sends only one DECIDE message, they must share the same vote
756
760
// in order to be aggregated.
757
761
i .broadcast (0 , DECIDE_PHASE , i .value , false , justification )
758
- metrics .phaseCounter .Add (context .TODO (), 1 , metric .WithAttributes (attrDecidePhase ))
759
- metrics .currentPhase .Record (context .TODO (), int64 (DECIDE_PHASE ))
762
+ i .reportPhaseMetrics ()
760
763
}
761
764
762
765
// Skips immediately to the DECIDE phase and sends a DECIDE message
@@ -770,9 +773,8 @@ func (i *instance) skipToDecide(value *ECChain, justification *Justification) {
770
773
i .resetRebroadcastParams ()
771
774
i .broadcast (0 , DECIDE_PHASE , i .value , false , justification )
772
775
773
- metrics .phaseCounter .Add (context .TODO (), 1 , metric .WithAttributes (attrDecidePhase ))
774
- metrics .currentPhase .Record (context .TODO (), int64 (DECIDE_PHASE ))
775
776
metrics .skipCounter .Add (context .TODO (), 1 , metric .WithAttributes (attrSkipToDecide ))
777
+ i .reportPhaseMetrics ()
776
778
}
777
779
778
780
func (i * instance ) tryDecide () error {
@@ -874,9 +876,8 @@ func (i *instance) terminate(decision *Justification) {
874
876
i .terminationValue = decision
875
877
i .resetRebroadcastParams ()
876
878
877
- metrics .phaseCounter .Add (context .TODO (), 1 , metric .WithAttributes (attrTerminatedPhase ))
878
879
metrics .roundHistogram .Record (context .TODO (), int64 (i .current .Round ))
879
- metrics . currentPhase . Record ( context . TODO (), int64 ( TERMINATED_PHASE ) )
880
+ i . reportPhaseMetrics ( )
880
881
}
881
882
882
883
func (i * instance ) terminated () bool {
0 commit comments