diff --git a/consul/catalog_endpoint.go b/consul/catalog_endpoint.go index e2075dbdd9..effd55b42c 100644 --- a/consul/catalog_endpoint.go +++ b/consul/catalog_endpoint.go @@ -2,7 +2,9 @@ package consul import ( "fmt" + "github.com/armon/go-metrics" "github.com/hashicorp/consul/consul/structs" + "time" ) // Catalog endpoint is used to manipulate the service catalog @@ -15,6 +17,7 @@ func (c *Catalog) Register(args *structs.RegisterRequest, reply *struct{}) error if done, err := c.srv.forward("Catalog.Register", args.Datacenter, args, reply); done { return err } + defer metrics.MeasureSince([]string{"consul", "catalog", "register"}, time.Now()) // Verify the args if args.Node == "" || args.Address == "" { @@ -55,6 +58,7 @@ func (c *Catalog) Deregister(args *structs.DeregisterRequest, reply *struct{}) e if done, err := c.srv.forward("Catalog.Deregister", args.Datacenter, args, reply); done { return err } + defer metrics.MeasureSince([]string{"consul", "catalog", "deregister"}, time.Now()) // Verify the args if args.Node == "" { diff --git a/consul/leader.go b/consul/leader.go index a527056373..94a8458d27 100644 --- a/consul/leader.go +++ b/consul/leader.go @@ -1,6 +1,7 @@ package consul import ( + "github.com/armon/go-metrics" "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/raft" "github.com/hashicorp/serf/serf" @@ -59,11 +60,13 @@ RECONCILE: interval := time.After(s.config.ReconcileInterval) // Apply a raft barrier to ensure our FSM is caught up + start := time.Now() barrier := s.raft.Barrier(0) if err := barrier.Error(); err != nil { s.logger.Printf("[ERR] consul: failed to wait for barrier: %v", err) goto WAIT } + metrics.MeasureSince([]string{"consul", "leader", "barrier"}, start) // Reconcile any missing data if err := s.reconcile(); err != nil { @@ -97,6 +100,7 @@ WAIT: // Mainly we need to ensure all live nodes are registered, all failed // nodes are marked as such, and all left nodes are de-registered. func (s *Server) reconcile() (err error) { + defer metrics.MeasureSince([]string{"consul", "leader", "reconcile"}, time.Now()) members := s.serfLAN.Members() for _, member := range members { if err := s.reconcileMember(member); err != nil { @@ -114,6 +118,7 @@ func (s *Server) reconcileMember(member serf.Member) error { s.logger.Printf("[WARN] consul: skipping reconcile of node %v", member) return nil } + defer metrics.MeasureSince([]string{"consul", "leader", "reconcileMember"}, time.Now()) var err error switch member.Status { case serf.StatusAlive: diff --git a/consul/rpc.go b/consul/rpc.go index b5899d465b..3f5d8913d1 100644 --- a/consul/rpc.go +++ b/consul/rpc.go @@ -2,6 +2,7 @@ package consul import ( "fmt" + "github.com/armon/go-metrics" "github.com/hashicorp/consul/consul/structs" "github.com/inconshreveable/muxado" "github.com/ugorji/go/codec" @@ -43,6 +44,7 @@ func (s *Server) listen() { s.rpcClientLock.Unlock() go s.handleConn(conn) + metrics.IncrCounter([]string{"consul", "rpc", "accept_conn"}, 1) } } @@ -63,6 +65,7 @@ func (s *Server) handleConn(conn net.Conn) { s.handleConsulConn(conn) case rpcRaft: + metrics.IncrCounter([]string{"consul", "rpc", "raft_handoff"}, 1) s.raftLayer.Handoff(conn) case rpcMultiplex: @@ -154,6 +157,7 @@ func (s *Server) forwardDC(method, dc string, args interface{}, reply interface{ s.remoteLock.RUnlock() // Forward to remote Consul + metrics.IncrCounter([]string{"consul", "rpc", "cross-dc", dc}, 1) return s.connPool.RPC(server, method, args, reply) } diff --git a/consul/server.go b/consul/server.go index b976e2caa3..91041dfdd5 100644 --- a/consul/server.go +++ b/consul/server.go @@ -17,7 +17,6 @@ const ( serfLANSnapshot = "serf/local.snapshot" serfWANSnapshot = "serf/remote.snapshot" raftState = "raft/" - bootstrapFlag = "b" ) // Server is Consul server which manages the service discovery,