fn: adding docker events to stats (#1262)

Streaming docker events is useful as we can record/capture some
asynchronous containers events such as out-of-memory. For now,
we record these in opencensus/prometheus stats.
This commit is contained in:
Tolga Ceylan
2018-10-04 18:54:09 -07:00
committed by GitHub
parent ec2f9539f2
commit 29dcf0a791
2 changed files with 74 additions and 6 deletions

View File

@@ -53,6 +53,7 @@ func (r *runResult) Error() error { return r.err }
func (r *runResult) Status() string { return r.status }
type DockerDriver struct {
cancel func()
conf drivers.Config
docker dockerClient // retries on *docker.Client, restricts ad hoc *docker.Client usage / retries
hostname string
@@ -75,9 +76,11 @@ func NewDocker(conf drivers.Config) *DockerDriver {
logrus.WithError(err).Fatal("couldn't initialize registry")
}
ctx, cancel := context.WithCancel(context.Background())
driver := &DockerDriver{
cancel: cancel,
conf: conf,
docker: newClient(),
docker: newClient(ctx),
hostname: hostname,
auths: auths,
}
@@ -145,6 +148,9 @@ func (drv *DockerDriver) Close() error {
if drv.pool != nil {
err = drv.pool.Close()
}
if drv.cancel != nil {
drv.cancel()
}
return err
}