diff --git a/cmd/containerd-stress/main.go b/cmd/containerd-stress/main.go index a53ca6e77..3b8929d89 100644 --- a/cmd/containerd-stress/main.go +++ b/cmd/containerd-stress/main.go @@ -23,6 +23,22 @@ import ( const imageName = "docker.io/library/alpine:latest" +var ( + ct metrics.LabeledTimer + errCounter metrics.LabeledCounter + binarySizeGauge metrics.LabeledGauge +) + +func init() { + ns := metrics.NewNamespace("stress", "", nil) + // if you want more fine grained metrics then you can drill down with the metrics in prom that + // containerd is outputing + ct = ns.NewLabeledTimer("run", "Run time of a full container during the test", "commit") + binarySizeGauge = ns.NewLabeledGauge("binary_size", "Binary size of compiled binaries", "name") + errCounter = ns.NewLabeledCounter("errors", "Errors encountered running the stress tests", "err") + metrics.Register(ns) +} + type run struct { total int failures int @@ -152,6 +168,7 @@ func serve(c config) error { logrus.WithError(err).Error("listen and serve") } }() + checkBinarySizes() return test(c) } diff --git a/cmd/containerd-stress/size.go b/cmd/containerd-stress/size.go new file mode 100644 index 000000000..88af033c2 --- /dev/null +++ b/cmd/containerd-stress/size.go @@ -0,0 +1,26 @@ +package main + +import ( + "os" + "path/filepath" + + "github.com/sirupsen/logrus" +) + +var binaries = []string{ + "ctr", + "containerd", + "containerd-shim", +} + +// checkBinarySizes checks and reports the binary sizes for the containerd compiled binaries to prometheus +func checkBinarySizes() { + for _, name := range binaries { + fi, err := os.Stat(filepath.Join("/usr/local/bin", name)) + if err != nil { + logrus.WithError(err).Error("stat binary") + continue + } + binarySizeGauge.WithValues(name).Set(float64(fi.Size())) + } +} diff --git a/cmd/containerd-stress/worker.go b/cmd/containerd-stress/worker.go index 2738555ab..19bf8552f 100644 --- a/cmd/containerd-stress/worker.go +++ b/cmd/containerd-stress/worker.go @@ -13,25 +13,10 @@ import ( "github.com/containerd/containerd" "github.com/containerd/containerd/cio" "github.com/containerd/containerd/oci" - metrics "github.com/docker/go-metrics" specs "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" ) -var ( - ct metrics.LabeledTimer - errCounter metrics.LabeledCounter -) - -func init() { - ns := metrics.NewNamespace("stress", "", nil) - // if you want more fine grained metrics then you can drill down with the metrics in prom that - // containerd is outputing - ct = ns.NewLabeledTimer("run", "Run time of a full container during the test", "commit") - errCounter = ns.NewLabeledCounter("errors", "Errors encountered running the stress tests", "err") - metrics.Register(ns) -} - type worker struct { id int wg *sync.WaitGroup