From 058eea362a94ff8152dc5c62f3c5c2494372e8ba Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Tue, 20 Sep 2016 10:14:53 -0700 Subject: [PATCH] Remove go-metrics Signed-off-by: Michael Crosby --- containerd/main.go | 38 ------------------------------- containerd/main_linux.go | 45 ------------------------------------- containerd/main_solaris.go | 4 ---- supervisor/add_process.go | 2 -- supervisor/create.go | 4 ---- supervisor/delete.go | 3 --- supervisor/exit.go | 4 ---- supervisor/metrics.go | 42 ---------------------------------- supervisor/monitor_linux.go | 4 ---- supervisor/stats.go | 8 +------ supervisor/supervisor.go | 4 ---- supervisor/worker.go | 2 -- 12 files changed, 1 insertion(+), 159 deletions(-) delete mode 100644 containerd/main_linux.go delete mode 100644 containerd/main_solaris.go delete mode 100644 supervisor/metrics.go diff --git a/containerd/main.go b/containerd/main.go index fec3666..febeac3 100644 --- a/containerd/main.go +++ b/containerd/main.go @@ -2,8 +2,6 @@ package main import ( "fmt" - "log" - "net" "os" "os/signal" "runtime" @@ -18,14 +16,12 @@ import ( "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" - "github.com/cyberdelia/go-metrics-graphite" "github.com/docker/containerd" "github.com/docker/containerd/api/grpc/server" "github.com/docker/containerd/api/grpc/types" "github.com/docker/containerd/api/http/pprof" "github.com/docker/containerd/supervisor" "github.com/docker/docker/pkg/listeners" - "github.com/rcrowley/go-metrics" ) const ( @@ -45,11 +41,6 @@ var daemonFlags = []cli.Flag{ Value: defaultStateDir, Usage: "runtime state directory", }, - cli.DurationFlag{ - Name: "metrics-interval", - Value: 5 * time.Minute, - Usage: "interval for flushing metrics to the store", - }, cli.StringFlag{ Name: "listen,l", Value: defaultGRPCEndpoint, @@ -84,10 +75,6 @@ var daemonFlags = []cli.Flag{ Value: 500, Usage: "number of past events to keep in the event log", }, - cli.StringFlag{ - Name: "graphite-address", - Usage: "Address of graphite server", - }, } // DumpStacks dumps the runtime stack. @@ -131,11 +118,6 @@ func main() { setupDumpStacksTrap() if context.GlobalBool("debug") { logrus.SetLevel(logrus.DebugLevel) - if context.GlobalDuration("metrics-interval") > 0 { - if err := debugMetrics(context.GlobalDuration("metrics-interval"), context.GlobalString("graphite-address")); err != nil { - return err - } - } } if p := context.GlobalString("pprof-address"); len(p) > 0 { pprof.Enable(p) @@ -248,23 +230,3 @@ func checkLimits() error { } return nil } - -func debugMetrics(interval time.Duration, graphiteAddr string) error { - for name, m := range supervisor.Metrics() { - if err := metrics.DefaultRegistry.Register(name, m); err != nil { - return err - } - } - processMetrics() - if graphiteAddr != "" { - addr, err := net.ResolveTCPAddr("tcp", graphiteAddr) - if err != nil { - return err - } - go graphite.Graphite(metrics.DefaultRegistry, 10e9, "metrics", addr) - } else { - l := log.New(os.Stdout, "[containerd] ", log.LstdFlags) - go metrics.Log(metrics.DefaultRegistry, interval, l) - } - return nil -} diff --git a/containerd/main_linux.go b/containerd/main_linux.go deleted file mode 100644 index 8ea0a4d..0000000 --- a/containerd/main_linux.go +++ /dev/null @@ -1,45 +0,0 @@ -package main - -import ( - "os" - "runtime" - "time" - - "github.com/Sirupsen/logrus" - "github.com/cloudfoundry/gosigar" - "github.com/docker/containerd/osutils" - "github.com/rcrowley/go-metrics" -) - -func processMetrics() { - var ( - g = metrics.NewGauge() - fg = metrics.NewGauge() - memg = metrics.NewGauge() - ) - metrics.DefaultRegistry.Register("goroutines", g) - metrics.DefaultRegistry.Register("fds", fg) - metrics.DefaultRegistry.Register("memory-used", memg) - collect := func() { - // update number of goroutines - g.Update(int64(runtime.NumGoroutine())) - // collect the number of open fds - fds, err := osutils.GetOpenFds(os.Getpid()) - if err != nil { - logrus.WithField("error", err).Error("containerd: get open fd count") - } - fg.Update(int64(fds)) - // get the memory used - m := sigar.ProcMem{} - if err := m.Get(os.Getpid()); err != nil { - logrus.WithField("error", err).Error("containerd: get pid memory information") - } - memg.Update(int64(m.Size)) - } - go func() { - collect() - for range time.Tick(30 * time.Second) { - collect() - } - }() -} diff --git a/containerd/main_solaris.go b/containerd/main_solaris.go deleted file mode 100644 index 7a95383..0000000 --- a/containerd/main_solaris.go +++ /dev/null @@ -1,4 +0,0 @@ -package main - -func processMetrics() { -} diff --git a/supervisor/add_process.go b/supervisor/add_process.go index ab0f689..e3c23f4 100644 --- a/supervisor/add_process.go +++ b/supervisor/add_process.go @@ -21,7 +21,6 @@ type AddProcessTask struct { } func (s *Supervisor) addProcess(t *AddProcessTask) error { - start := time.Now() ci, ok := s.containers[t.ID] if !ok { return ErrContainerNotFound @@ -33,7 +32,6 @@ func (s *Supervisor) addProcess(t *AddProcessTask) error { if err := s.monitorProcess(process); err != nil { return err } - ExecProcessTimer.UpdateSince(start) t.StartResponse <- StartResponse{} s.notifySubscribers(Event{ Timestamp: time.Now(), diff --git a/supervisor/create.go b/supervisor/create.go index fa0defe..fa3468c 100644 --- a/supervisor/create.go +++ b/supervisor/create.go @@ -2,7 +2,6 @@ package supervisor import ( "path/filepath" - "time" "github.com/docker/containerd/runtime" ) @@ -25,7 +24,6 @@ type StartTask struct { } func (s *Supervisor) start(t *StartTask) error { - start := time.Now() rt := s.runtime rtArgs := s.runtimeArgs if t.Runtime != "" { @@ -49,7 +47,6 @@ func (s *Supervisor) start(t *StartTask) error { s.containers[t.ID] = &containerInfo{ container: container, } - ContainersCounter.Inc(1) task := &startTask{ Err: t.ErrorCh(), Container: container, @@ -63,6 +60,5 @@ func (s *Supervisor) start(t *StartTask) error { } s.startTasks <- task - ContainerCreateTimer.UpdateSince(start) return errDeferredResponse } diff --git a/supervisor/delete.go b/supervisor/delete.go index 72dbc80..4df53d8 100644 --- a/supervisor/delete.go +++ b/supervisor/delete.go @@ -19,7 +19,6 @@ type DeleteTask struct { func (s *Supervisor) delete(t *DeleteTask) error { if i, ok := s.containers[t.ID]; ok { - start := time.Now() if err := s.deleteContainer(i.container); err != nil { logrus.WithField("error", err).Error("containerd: deleting container") } @@ -35,8 +34,6 @@ func (s *Supervisor) delete(t *DeleteTask) error { PID: t.PID, }) } - ContainersCounter.Dec(1) - ContainerDeleteTimer.UpdateSince(start) } return nil } diff --git a/supervisor/exit.go b/supervisor/exit.go index faf92bf..f9f8580 100644 --- a/supervisor/exit.go +++ b/supervisor/exit.go @@ -14,7 +14,6 @@ type ExitTask struct { } func (s *Supervisor) exit(t *ExitTask) error { - start := time.Now() proc := t.Process status, err := proc.ExitStatus() if err != nil { @@ -52,9 +51,6 @@ func (s *Supervisor) exit(t *ExitTask) error { Process: proc, } s.delete(ne) - - ExitProcessTimer.UpdateSince(start) - return nil } diff --git a/supervisor/metrics.go b/supervisor/metrics.go deleted file mode 100644 index e49170d..0000000 --- a/supervisor/metrics.go +++ /dev/null @@ -1,42 +0,0 @@ -package supervisor - -import "github.com/rcrowley/go-metrics" - -var ( - // ContainerCreateTimer holds the metrics timer associated with container creation - ContainerCreateTimer = metrics.NewTimer() - // ContainerDeleteTimer holds the metrics timer associated with container deletion - ContainerDeleteTimer = metrics.NewTimer() - // ContainerStartTimer holds the metrics timer associated with container start duration - ContainerStartTimer = metrics.NewTimer() - // ContainerStatsTimer holds the metrics timer associated with container stats generation - ContainerStatsTimer = metrics.NewTimer() - // ContainersCounter keeps track of the number of active containers - ContainersCounter = metrics.NewCounter() - // EventSubscriberCounter keeps track of the number of active event subscribers - EventSubscriberCounter = metrics.NewCounter() - // TasksCounter keeps track of the number of active supervisor tasks - TasksCounter = metrics.NewCounter() - // ExecProcessTimer holds the metrics timer associated with container exec - ExecProcessTimer = metrics.NewTimer() - // ExitProcessTimer holds the metrics timer associated with reporting container exit status - ExitProcessTimer = metrics.NewTimer() - // EpollFdCounter keeps trac of how many process are being monitored - EpollFdCounter = metrics.NewCounter() -) - -// Metrics return the list of all available metrics -func Metrics() map[string]interface{} { - return map[string]interface{}{ - "container-create-time": ContainerCreateTimer, - "container-delete-time": ContainerDeleteTimer, - "container-start-time": ContainerStartTimer, - "container-stats-time": ContainerStatsTimer, - "containers": ContainersCounter, - "event-subscribers": EventSubscriberCounter, - "tasks": TasksCounter, - "exec-process-time": ExecProcessTimer, - "exit-process-time": ExitProcessTimer, - "epoll-fds": EpollFdCounter, - } -} diff --git a/supervisor/monitor_linux.go b/supervisor/monitor_linux.go index d308aa9..8875a19 100644 --- a/supervisor/monitor_linux.go +++ b/supervisor/monitor_linux.go @@ -56,7 +56,6 @@ func (m *Monitor) Monitor(p runtime.Process) error { if err := archutils.EpollCtl(m.epollFd, syscall.EPOLL_CTL_ADD, fd, &event); err != nil { return err } - EpollFdCounter.Inc(1) m.receivers[fd] = p return nil } @@ -77,7 +76,6 @@ func (m *Monitor) MonitorOOM(c runtime.Container) error { if err := archutils.EpollCtl(m.epollFd, syscall.EPOLL_CTL_ADD, fd, &event); err != nil { return err } - EpollFdCounter.Inc(1) m.receivers[fd] = o return nil } @@ -115,7 +113,6 @@ func (m *Monitor) start() { if err := t.Close(); err != nil { logrus.WithField("error", err).Error("containerd: close process IO") } - EpollFdCounter.Dec(1) m.exits <- t } case runtime.OOM: @@ -125,7 +122,6 @@ func (m *Monitor) start() { delete(m.receivers, fd) // epoll will remove the fd from its set after it has been closed t.Close() - EpollFdCounter.Dec(1) } else { m.ooms <- t.ContainerID() } diff --git a/supervisor/stats.go b/supervisor/stats.go index cc169ad..6fc0797 100644 --- a/supervisor/stats.go +++ b/supervisor/stats.go @@ -1,10 +1,6 @@ package supervisor -import ( - "time" - - "github.com/docker/containerd/runtime" -) +import "github.com/docker/containerd/runtime" // StatsTask holds needed parameters to retrieve a container statistics type StatsTask struct { @@ -14,7 +10,6 @@ type StatsTask struct { } func (s *Supervisor) stats(t *StatsTask) error { - start := time.Now() i, ok := s.containers[t.ID] if !ok { return ErrContainerNotFound @@ -28,7 +23,6 @@ func (s *Supervisor) stats(t *StatsTask) error { } t.ErrorCh() <- nil t.Stat <- s - ContainerStatsTimer.UpdateSince(start) }() return errDeferredResponse } diff --git a/supervisor/supervisor.go b/supervisor/supervisor.go index c1232f2..4306cf6 100644 --- a/supervisor/supervisor.go +++ b/supervisor/supervisor.go @@ -214,7 +214,6 @@ func (s *Supervisor) Events(from time.Time, storedOnly bool, id string) chan Eve if storedOnly { close(c) } else { - EventSubscriberCounter.Inc(1) s.subscribers[c] = struct{}{} } return c @@ -227,7 +226,6 @@ func (s *Supervisor) Unsubscribe(sub chan Event) { if _, ok := s.subscribers[sub]; ok { delete(s.subscribers, sub) close(sub) - EventSubscriberCounter.Dec(1) } } @@ -276,7 +274,6 @@ func (s *Supervisor) Machine() Machine { // SendTask sends the provided event the the supervisors main event loop func (s *Supervisor) SendTask(evt Task) { - TasksCounter.Inc(1) s.tasks <- evt } @@ -321,7 +318,6 @@ func (s *Supervisor) restore() error { return err } - ContainersCounter.Inc(1) s.containers[id] = &containerInfo{ container: container, } diff --git a/supervisor/worker.go b/supervisor/worker.go index 250d396..cfb6700 100644 --- a/supervisor/worker.go +++ b/supervisor/worker.go @@ -40,7 +40,6 @@ type worker struct { func (w *worker) Start() { defer w.wg.Done() for t := range w.s.startTasks { - started := time.Now() process, err := t.Container.Start(t.CheckpointPath, runtime.NewStdio(t.Stdin, t.Stdout, t.Stderr)) if err != nil { logrus.WithFields(logrus.Fields{ @@ -87,7 +86,6 @@ func (w *worker) Start() { continue } } - ContainerStartTimer.UpdateSince(started) t.Err <- nil t.StartResponse <- StartResponse{ Container: t.Container,