From d63300d08ffcffbec6492fb830bfa36f34d54a75 Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Tue, 9 Oct 2018 17:27:51 -0700 Subject: [PATCH] Port client portion of #4392 to new taskrunner PR #4392 was merged to master *after* allocrunnerv2 was branched, so the client-specific portions must be ported from master to arv2. --- client/allocrunner/taskrunner/task_runner.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/client/allocrunner/taskrunner/task_runner.go b/client/allocrunner/taskrunner/task_runner.go index a9d10dc19de5..c3a49c94a43b 100644 --- a/client/allocrunner/taskrunner/task_runner.go +++ b/client/allocrunner/taskrunner/task_runner.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "strings" "sync" "time" @@ -277,6 +278,25 @@ func (tr *TaskRunner) initLabels() { Value: tr.taskName, }, } + + if tr.alloc.Job.ParentID != "" { + tr.baseLabels = append(tr.baseLabels, metrics.Label{ + Name: "parent_id", + Value: tr.alloc.Job.ParentID, + }) + if strings.Contains(tr.alloc.Job.Name, "/dispatch-") { + tr.baseLabels = append(tr.baseLabels, metrics.Label{ + Name: "dispatch_id", + Value: strings.Split(tr.alloc.Job.Name, "/dispatch-")[1], + }) + } + if strings.Contains(tr.alloc.Job.Name, "/periodic-") { + tr.baseLabels = append(tr.baseLabels, metrics.Label{ + Name: "periodic_id", + Value: strings.Split(tr.alloc.Job.Name, "/periodic-")[1], + }) + } + } } func (tr *TaskRunner) Run() {