-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4386: BlockRateController: Metrics and debug logging r=jordanschalm a=jordanschalm Co-authored-by: Jordan Schalm <jordan@dapperlabs.com>
- Loading branch information
Showing
6 changed files
with
232 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package metrics | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/prometheus/client_golang/prometheus/promauto" | ||
) | ||
|
||
// CruiseCtlMetrics captures metrics about the Block Rate Controller, which adjusts | ||
// the proposal duration to attain a target epoch switchover time. | ||
type CruiseCtlMetrics struct { | ||
proportionalErr prometheus.Gauge | ||
integralErr prometheus.Gauge | ||
derivativeErr prometheus.Gauge | ||
targetProposalDur prometheus.Gauge | ||
controllerOutput prometheus.Gauge | ||
} | ||
|
||
func NewCruiseCtlMetrics() *CruiseCtlMetrics { | ||
return &CruiseCtlMetrics{ | ||
proportionalErr: promauto.NewGauge(prometheus.GaugeOpts{ | ||
Name: "proportional_err_s", | ||
Namespace: namespaceConsensus, | ||
Subsystem: subsystemCruiseCtl, | ||
Help: "The current proportional error measured by the controller", | ||
}), | ||
integralErr: promauto.NewGauge(prometheus.GaugeOpts{ | ||
Name: "integral_err_s", | ||
Namespace: namespaceConsensus, | ||
Subsystem: subsystemCruiseCtl, | ||
Help: "The current integral error measured by the controller", | ||
}), | ||
derivativeErr: promauto.NewGauge(prometheus.GaugeOpts{ | ||
Name: "derivative_err_per_s", | ||
Namespace: namespaceConsensus, | ||
Subsystem: subsystemCruiseCtl, | ||
Help: "The current derivative error measured by the controller", | ||
}), | ||
targetProposalDur: promauto.NewGauge(prometheus.GaugeOpts{ | ||
Name: "target_proposal_dur_s", | ||
Namespace: namespaceConsensus, | ||
Subsystem: subsystemCruiseCtl, | ||
Help: "The current target duration for a proposal", | ||
}), | ||
controllerOutput: promauto.NewGauge(prometheus.GaugeOpts{ | ||
Name: "controller_output_s", | ||
Namespace: namespaceConsensus, | ||
Subsystem: subsystemCruiseCtl, | ||
Help: "The most recent output of the controller; the adjust to subtract from the baseline proposal duration", | ||
}), | ||
} | ||
} | ||
|
||
func (c *CruiseCtlMetrics) PIDError(p, i, d float64) { | ||
c.proportionalErr.Set(p) | ||
c.integralErr.Set(i) | ||
c.derivativeErr.Set(d) | ||
} | ||
|
||
func (c *CruiseCtlMetrics) TargetProposalDuration(duration time.Duration) { | ||
c.targetProposalDur.Set(duration.Seconds()) | ||
} | ||
|
||
func (c *CruiseCtlMetrics) ControllerOutput(duration time.Duration) { | ||
c.controllerOutput.Set(duration.Seconds()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.