Skip to content

Commit

Permalink
addressing pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
otherview committed Mar 10, 2021
1 parent c7868b0 commit 19b89df
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions api/health/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ type Service interface {
}

func NewService(checkFreq time.Duration, log logging.Logger, registry prometheus.Registerer) (Service, error) {
healthL, err := healthlib.NewService(checkFreq, log, registry)
service, err := healthlib.NewService(checkFreq, log, registry)
if err != nil {
return nil, err
}
return &apiServer{
Service: healthL,
Service: service,
log: log,
}, nil
}
Expand Down
6 changes: 2 additions & 4 deletions health/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/wrappers"
"github.com/prometheus/client_golang/prometheus"

health "github.com/AppsFlyer/go-sundheit"
)

// metrics reports commonly used health check metrics.
Expand Down Expand Up @@ -39,11 +37,11 @@ func newMetrics(log logging.Logger, namespace string, registerer prometheus.Regi
}

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

// unHealthy handles the metrics for the unhealthy cases
func (m *metrics) unHealthy(health.Result) {
func (m *metrics) unHealthy() {
m.failingChecks.Inc()
}
8 changes: 4 additions & 4 deletions health/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,19 @@ func (c *checkListener) OnCheckCompleted(name string, result health.Result) {
if !exists || isHealthy == previouslyHealthy {
if isHealthy {
c.log.Debug("%q returned healthy with: %s", name, string(resultJSON))
c.metrics.healthy(result)
c.metrics.healthy()
} else {
c.log.Debug("%q returned unhealthy with: %s", name, string(resultJSON))
c.metrics.unHealthy(result)
c.metrics.unHealthy()
}
return
}

if isHealthy {
c.log.Info("%q became healthy with: %s", name, string(resultJSON))
c.metrics.healthy(result)
c.metrics.healthy()
} else {
c.log.Warn("%q became unhealthy with: %s", name, string(resultJSON))
c.metrics.unHealthy(result)
c.metrics.unHealthy()
}
}
2 changes: 1 addition & 1 deletion network/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ func (p *peer) GetPeerList() {
p.net.log.AssertNoError(err)
p.Send(msg)
p.net.getPeerlist.numReceived.Inc()
p.net.getPeerlist.sentBytes.Add(float64(len(msg.Bytes())))
p.net.getPeerlist.receivedBytes.Add(float64(len(msg.Bytes())))
}

// assumes the stateLock is not held
Expand Down

0 comments on commit 19b89df

Please sign in to comment.