Skip to content

Commit

Permalink
Drop RCrowleys sample metrics
Browse files Browse the repository at this point in the history
Also rename metrics packages for simplicity.
  • Loading branch information
panchoh authored and iknite committed Feb 19, 2019
1 parent 4f0ae78 commit 76d1d4d
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions api/apihttp/apihttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,11 @@ import (
"time"

"github.com/bbva/qed/log"
qedMetrics "github.com/bbva/qed/metrics"
"github.com/bbva/qed/metrics"
"github.com/bbva/qed/protocol"
"github.com/bbva/qed/raftwal"

"github.com/prometheus/client_golang/prometheus"
"github.com/rcrowley/go-metrics"
)

var (
// Crowley:
cOpsProcessed = metrics.NewCounter()
)

// HealthCheckResponse contains the response from HealthCheckHandler.
Expand All @@ -53,21 +47,15 @@ type HealthCheckResponse struct {
// If everything is allright, the HTTP status is 200 and the body contains:
// {"version": "0", "status":"ok"}
func HealthCheckHandler(w http.ResponseWriter, r *http.Request) {
timer := prometheus.NewTimer(qedMetrics.RequestDuration)
timer := prometheus.NewTimer(metrics.RequestDuration)
defer timer.ObserveDuration()

timer2 := prometheus.NewTimer(prometheus.ObserverFunc(qedMetrics.FuncDuration.Set))
timer2 := prometheus.NewTimer(prometheus.ObserverFunc(metrics.FuncDuration.Set))
defer timer2.ObserveDuration()

// Do something here that takes time.
time.Sleep(time.Duration(rand.NormFloat64()*10000+50000) * time.Microsecond)

// Prometheus
qedMetrics.OpsProcessed.Inc()

// Crowley
cOpsProcessed.Inc(1)

result := HealthCheckResponse{
Version: 0,
Status: "ok",
Expand Down Expand Up @@ -326,8 +314,6 @@ func AuthHandlerMiddleware(handler http.HandlerFunc) http.HandlerFunc {
// /events -> Add
// /proofs/membership -> Membership
func NewApiHttp(balloon raftwal.RaftBalloonApi) *http.ServeMux {
metrics.Register("healthcheck_ops_total", cOpsProcessed)

api := http.NewServeMux()
api.HandleFunc("/health-check", AuthHandlerMiddleware(HealthCheckHandler))
api.HandleFunc("/events", AuthHandlerMiddleware(Add(balloon)))
Expand Down

0 comments on commit 76d1d4d

Please sign in to comment.