Add basic stats

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2015-11-30 15:34:01 -08:00
parent c42c9aeb06
commit 3a30ea0c4f
3 changed files with 25 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import (
"path/filepath"
"runtime"
"sync"
"time"
"github.com/Sirupsen/logrus"
"github.com/opencontainers/runc/libcontainer"
@@ -107,6 +108,7 @@ func (s *Supervisor) Start(events chan *Event) error {
continue
}
s.containers[e.ID] = container
ContainersCounter.Inc(1)
s.tasks <- &startTask{
err: e.Err,
container: container,
@@ -117,6 +119,7 @@ func (s *Supervisor) Start(events chan *Event) error {
if err := s.deleteContainer(container); err != nil {
logrus.WithField("error", err).Error("containerd: deleting container")
}
ContainersCounter.Dec(1)
}
case GetContainerEventType:
for _, c := range s.containers {
@@ -222,6 +225,7 @@ type startTask struct {
func (s *Supervisor) startContainerWorker(tasks chan *startTask) {
defer s.workerGroup.Done()
for t := range tasks {
started := time.Now()
if err := t.container.Start(); err != nil {
e := NewEvent(StartContainerEventType)
e.ID = t.container.ID()
@@ -229,6 +233,7 @@ func (s *Supervisor) startContainerWorker(tasks chan *startTask) {
t.err <- err
continue
}
ContainerStartTimer.UpdateSince(started)
t.err <- nil
}
}