Skip to content

Commit

Permalink
making health metrics private
Browse files Browse the repository at this point in the history
  • Loading branch information
otherview committed Mar 9, 2021
1 parent 31237ac commit 73b7bcd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions health/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import (
"github.com/ava-labs/avalanchego/utils/wrappers"
)

// Metrics reports commonly used health check metrics.
type Metrics struct {
// metrics reports commonly used health check 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{
func newMetrics(log logging.Logger, namespace string, registerer prometheus.Registerer) (*metrics, error) {
metrics := &metrics{
log: log,
failingChecks: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Expand All @@ -39,11 +39,11 @@ func newMetrics(metricName, descriptionName string, log logging.Logger, namespac
}

// healthy handles the metrics for the healthy cases
func (m *Metrics) healthy(health.Result) {
func (m *metrics) healthy(health.Result) {
m.failingChecks.Dec()
}

// unHealthy handles the metrics for the unhealthy cases
func (m *Metrics) unHealthy(health.Result) {
func (m *metrics) unHealthy(health.Result) {
m.failingChecks.Inc()
}
4 changes: 2 additions & 2 deletions health/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Service interface {
// run every [checkFreq]
func NewService(checkFreq time.Duration, log logging.Logger, registry prometheus.Registerer) (Service, error) {
healthChecker := health.New()
metrics, err := newMetrics("healthCheck", "healthCheck metrics", log, "healthcheck", registry)
metrics, err := newMetrics(log, "healthcheck", registry)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -86,7 +86,7 @@ type checkListener struct {
lock sync.Mutex
// checks maps name -> is healthy
checks map[string]bool
metrics *Metrics
metrics *metrics
}

func (c *checkListener) OnCheckStarted(name string) {
Expand Down

0 comments on commit 73b7bcd

Please sign in to comment.