Remove go-metrics
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
0645faf690
commit
058eea362a
12 changed files with 1 additions and 159 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}()
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
package main
|
||||
|
||||
func processMetrics() {
|
||||
}
|
|
@ -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(),
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue