mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user