forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
84 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// (c) 2019-2021, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package health | ||
|
||
import ( | ||
health "github.com/AppsFlyer/go-sundheit" | ||
"github.com/prometheus/client_golang/prometheus" | ||
|
||
"github.com/ava-labs/avalanchego/utils/logging" | ||
"github.com/ava-labs/avalanchego/utils/wrappers" | ||
) | ||
|
||
// Metrics reports commonly used consensus metrics. | ||
type Metrics struct { | ||
// log reports anomalous events. | ||
log logging.Logger | ||
|
||
// failingChecks keeps track of the number of check failing | ||
failingChecks prometheus.Gauge | ||
} | ||
|
||
func newMetrics(metricName, descriptionName string, log logging.Logger, namespace string, registerer prometheus.Registerer) (*Metrics, error) { | ||
metrics := &Metrics{ | ||
log: log, | ||
failingChecks: prometheus.NewGauge(prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "health_checks_failing", | ||
Help: "number of currently failing health checks", | ||
}), | ||
} | ||
|
||
errs := wrappers.Errs{} | ||
errs.Add( | ||
registerer.Register(metrics.failingChecks), | ||
) | ||
|
||
return metrics, errs.Err | ||
} | ||
|
||
// Healthy handles the metrics for the healthy cases | ||
func (m *Metrics) Healthy(json health.Result) { | ||
m.failingChecks.Dec() | ||
} | ||
|
||
// UnHealthy handles the metrics for the unhealthy cases | ||
func (m *Metrics) UnHealthy(result health.Result) { | ||
m.failingChecks.Inc() | ||
} |
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