mirror of https://github.com/status-im/consul.git
consul: Adding telemetry
This commit is contained in:
parent
dca8c79576
commit
889297dc99
|
@ -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 == "" {
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue