mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-10 14:00:33 +00:00
comments on proxy metrics
This commit is contained in:
@@ -242,6 +242,10 @@ func (app *appConnSnapshot) ApplySnapshotChunkSync(
|
||||
return app.appConn.ApplySnapshotChunkSync(ctx, req)
|
||||
}
|
||||
|
||||
// addTimeSample returns a function that, when called, adds an observation to m.
|
||||
// The observation added to m is the number of seconds ellapsed since addTimeSample
|
||||
// was initially called. addTimeSample is meant to be called in a defer to calculate
|
||||
// the amount of time a function takes to complete.
|
||||
func addTimeSample(m metrics.Histogram) func() {
|
||||
start := time.Now()
|
||||
return func() { m.Observe(time.Since(start).Seconds()) }
|
||||
|
||||
@@ -13,10 +13,15 @@ const (
|
||||
MetricsSubsystem = "abci_connection"
|
||||
)
|
||||
|
||||
// Metrics contains the prometheus metrics exposed by the proxy package.
|
||||
type Metrics struct {
|
||||
MethodTiming metrics.Histogram
|
||||
}
|
||||
|
||||
// PrometheusMetrics constructs a Metrics instance that collects metrics samples.
|
||||
// The resulting metrics will be prefixed with namespace and labeled with the
|
||||
// defaultLabelsAndValues. defaultLabelsAndValues must be a list of string pairs
|
||||
// where the first of each pair is the label and the second is the value.
|
||||
func PrometheusMetrics(namespace string, defaultLabelsAndValues ...string) *Metrics {
|
||||
defaultLabels := []string{}
|
||||
for i := 0; i < len(defaultLabelsAndValues); i += 2 {
|
||||
@@ -33,6 +38,8 @@ func PrometheusMetrics(namespace string, defaultLabelsAndValues ...string) *Metr
|
||||
}
|
||||
}
|
||||
|
||||
// NopMetrics constructs a Metrics instance that discards all samples and is suitable
|
||||
// for testing.
|
||||
func NopMetrics() *Metrics {
|
||||
return &Metrics{
|
||||
MethodTiming: discard.NewHistogram(),
|
||||
|
||||
Reference in New Issue
Block a user