-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new template counting and phase counting metrics
From #12589. New metric `total_count` which is like the old `count` metric and the new `gauge` metric, but a counter, not a gauge. The gauge shows a snapshot of what is happening right now in the cluster, the counter can answer questions like how many `Failed` workflows have there been in the last 24 hours. Two further metrics for counting uses of WorkflowTemplates via workflowTemplateRef only. These store the name of the WorkflowTemplate or ClusterWorkflowTemplate if the `cluster_scope` label is true, and the namespace where it is used. `workflowtemplate_triggered_total` counts the number of uses. `workflowtemplate_runtime` records how long each phase the workflow running the template spent in seconds. Note to reviewers: this is part of a stack of reviews for metrics changes. Please don't merge until the rest of the stack is also ready. Signed-off-by: Alan Clucas <[email protected]>
- Loading branch information
Showing
11 changed files
with
213 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: templateref-metrics- | ||
spec: | ||
workflowTemplateRef: | ||
name: basic | ||
clusterScope: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: templateref-metrics- | ||
spec: | ||
workflowTemplateRef: | ||
name: basic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package metrics | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
const ( | ||
nameWFTemplateTriggered = `workflowtemplate_triggered_total` | ||
) | ||
|
||
func addWorkflowTemplateCounter(_ context.Context, m *Metrics) error { | ||
return m.createInstrument(int64Counter, | ||
nameWFTemplateTriggered, | ||
"Total number of workflow templates triggered by workflowTemplateRef", | ||
"{workflow_template}", | ||
withAsBuiltIn(), | ||
) | ||
} | ||
|
||
func templateLabels(name, namespace string, cluster bool) instAttribs { | ||
return instAttribs{ | ||
{name: labelTemplateName, value: name}, | ||
{name: labelTemplateNamespace, value: namespace}, | ||
{name: labelTemplateCluster, value: cluster}, | ||
} | ||
} | ||
|
||
func (m *Metrics) CountWorkflowTemplate(ctx context.Context, phase, name, namespace string, cluster bool) { | ||
labels := templateLabels(name, namespace, cluster) | ||
labels = append(labels, instAttrib{name: labelWorkflowPhase, value: phase}) | ||
|
||
m.addInt(ctx, nameWFTemplateTriggered, 1, labels) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package metrics | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
const ( | ||
nameWorkflowPhaseCounter = `total_count` | ||
) | ||
|
||
func addWorkflowPhaseCounter(_ context.Context, m *Metrics) error { | ||
return m.createInstrument(int64Counter, | ||
nameWorkflowPhaseCounter, | ||
"Total number of workflows that have entered each phase", | ||
"{workflow}", | ||
withAsBuiltIn(), | ||
) | ||
} | ||
|
||
func (m *Metrics) ChangeWorkflowPhase(ctx context.Context, phase, namespace string) { | ||
m.addInt(ctx, nameWorkflowPhaseCounter, 1, instAttribs{ | ||
{name: labelWorkflowPhase, value: phase}, | ||
{name: labelWorkflowNamespace, value: namespace}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package metrics | ||
|
||
import ( | ||
"context" | ||
"time" | ||
) | ||
|
||
const ( | ||
nameWorkflowTemplateRuntime = `workflowtemplate_runtime` | ||
) | ||
|
||
func addWorkflowTemplateHistogram(_ context.Context, m *Metrics) error { | ||
return m.createInstrument(float64Histogram, | ||
nameWorkflowTemplateRuntime, | ||
"Duration of workflow template runs run through workflowTemplateRefs", | ||
"s", | ||
withAsBuiltIn(), | ||
) | ||
} | ||
|
||
func (m *Metrics) RecordWorkflowTemplateTime(ctx context.Context, duration time.Duration, name, namespace string, cluster bool) { | ||
m.record(ctx, nameWorkflowTemplateRuntime, duration.Seconds(), templateLabels(name, namespace, cluster)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters