Skip to content

Commit

Permalink
Drop dependency on github.com/deathowl/go-metrics-prometheus
Browse files Browse the repository at this point in the history
It seems we won't be needing it, since we are going to instrument natively with
prometheus in most cases.
  • Loading branch information
panchoh authored and iknite committed Feb 19, 2019
1 parent 324c321 commit 4f0ae78
Showing 1 changed file with 10 additions and 39 deletions.
49 changes: 10 additions & 39 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"net/http"
_ "net/http/pprof" // this will enable the default profiling capabilities
"os"
"time"

"github.com/bbva/qed/api/apihttp"
"github.com/bbva/qed/api/metricshttp"
Expand All @@ -45,27 +44,23 @@ import (
"github.com/bbva/qed/sign"
"github.com/bbva/qed/storage/badger"
"github.com/bbva/qed/util"
metricsprom "github.com/deathowl/go-metrics-prometheus"
"github.com/prometheus/client_golang/prometheus"
"github.com/rcrowley/go-metrics"
)

// Server encapsulates the data and login to start/stop a QED server
type Server struct {
conf *Config
bootstrap bool // Set bootstrap to true when bringing up the first node as a master

httpServer *http.Server
mgmtServer *http.Server
raftBalloon *raftwal.RaftBalloon
tamperingServer *http.Server
profilingServer *http.Server
metricsServer *http.Server
signer sign.Signer
sender *sender.Sender
agent *gossip.Agent
agentsQueue chan *protocol.Snapshot
metricsUpdaterControl chan bool
httpServer *http.Server
mgmtServer *http.Server
raftBalloon *raftwal.RaftBalloon
tamperingServer *http.Server
profilingServer *http.Server
metricsServer *http.Server
signer sign.Signer
sender *sender.Sender
agent *gossip.Agent
agentsQueue chan *protocol.Snapshot
}

func serverInfo(conf *Config) http.HandlerFunc {
Expand Down Expand Up @@ -172,7 +167,6 @@ func NewServer(conf *Config) (*Server, error) {
server.profilingServer = newHTTPServer("localhost:6060", nil)
}
if conf.EnableMetrics {
server.metricsUpdaterControl = make(chan bool)
metricsMux := metricshttp.NewMetricsHttp()
server.metricsServer = newHTTPServer("localhost:9990", metricsMux)
}
Expand Down Expand Up @@ -207,26 +201,6 @@ func (s *Server) Start() error {
}

if s.conf.EnableMetrics {
go func() {
pClient := metricsprom.NewPrometheusProvider(
metrics.DefaultRegistry,
"qed",
"crowley",
prometheus.DefaultRegisterer,
1*time.Second,
)

ticker := time.NewTicker(pClient.FlushInterval)
for {
select {
case <-ticker.C:
_ = pClient.UpdatePrometheusMetricsOnce()
case <-s.metricsUpdaterControl:
return
}
}
}()

go func() {
log.Debugf(" * Starting metrics HTTP server in addr: localhost:9990")
if err := s.metricsServer.ListenAndServe(); err != http.ErrServerClosed {
Expand Down Expand Up @@ -315,9 +289,6 @@ func (s *Server) Stop() error {
return err
}
log.Debugf("Done.\n")

s.metricsUpdaterControl <- true
close(s.metricsUpdaterControl)
}

if s.tamperingServer != nil {
Expand Down

0 comments on commit 4f0ae78

Please sign in to comment.