Skip to content

Commit 652e078

Browse files
committed
Add commit to stress metric
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
1 parent 4d55298 commit 652e078

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

cmd/containerd-stress/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ func test(c config) error {
192192
if c.Exec {
193193
args = oci.WithProcessArgs("sleep", "10")
194194
}
195+
v, err := client.Version(ctx)
196+
if err != nil {
197+
return err
198+
}
195199
// create the workers along with their spec
196200
for i := 0; i < c.Concurrency; i++ {
197201
wg.Add(1)
@@ -210,6 +214,7 @@ func test(c config) error {
210214
image: image,
211215
client: client,
212216
doExec: c.Exec,
217+
commit: v.Revision,
213218
}
214219
workers = append(workers, w)
215220
}

cmd/containerd-stress/worker.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ import (
1818
"github.com/sirupsen/logrus"
1919
)
2020

21-
var ct metrics.Timer
21+
var ct metrics.LabeledTimer
2222

2323
func init() {
2424
ns := metrics.NewNamespace("stress", "", nil)
2525
// if you want more fine grained metrics then you can drill down with the metrics in prom that
2626
// containerd is outputing
27-
ct = ns.NewTimer("run", "Run time of a full container during the test")
27+
ct = ns.NewLabeledTimer("run", "Run time of a full container during the test", "commit")
2828
metrics.Register(ns)
2929
}
3030

@@ -38,6 +38,7 @@ type worker struct {
3838
image containerd.Image
3939
spec *specs.Spec
4040
doExec bool
41+
commit string
4142
}
4243

4344
func (w *worker) run(ctx, tctx context.Context) {
@@ -66,7 +67,7 @@ func (w *worker) run(ctx, tctx context.Context) {
6667
continue
6768
}
6869
// only log times are success so we don't scew the results from failures that go really fast
69-
ct.UpdateSince(start)
70+
ct.WithValues(w.commit).UpdateSince(start)
7071
}
7172
}
7273

0 commit comments

Comments
 (0)