-
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: concurrency policy triggered counter metric
Add a new metric called `cronworkflows_concurrencypolicy_triggered` which counts the number of times a CronWorkflows `concurrencyPolicy` has changed something. The `concurency_policy` attribute can be: * `Forbid`: Counts the number of times a workflow was not started because one was already running * `Replace`: Counts the number of times a workflow was terminated because it was being replaced This PR moves the call to increment `cronworkflows_triggered_total` so that it doesn't count workflow runs suppressed by `Forbid`. This is documented and the test updated to test it. This PR also tidies some of the metrics documentation and language around CronWorkflows. Signed-off-by: Alan Clucas <[email protected]>
- Loading branch information
Showing
9 changed files
with
101 additions
and
16 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
11 changes: 6 additions & 5 deletions
11
test/e2e/testdata/cronworkflow-metrics.yaml → ...testdata/cronworkflow-metrics-forbid.yaml
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 |
---|---|---|
@@ -1,19 +1,20 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: CronWorkflow | ||
metadata: | ||
name: test-cron-metric | ||
name: test-cron-metric-forbid | ||
spec: | ||
schedule: "* * * * *" | ||
concurrencyPolicy: "Allow" | ||
concurrencyPolicy: "Forbid" | ||
startingDeadlineSeconds: 0 | ||
workflowSpec: | ||
metadata: | ||
labels: | ||
workflows.argoproj.io/test: "true" | ||
podGC: | ||
strategy: OnPodCompletion | ||
entrypoint: whalesay | ||
entrypoint: sleep | ||
templates: | ||
- name: whalesay | ||
- name: sleep | ||
container: | ||
image: argoproj/argosay:v2 | ||
image: alpine:latest | ||
command: [sh, -c, "sleep 120"] |
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,20 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: CronWorkflow | ||
metadata: | ||
name: test-cron-metric-replace | ||
spec: | ||
schedule: "* * * * *" | ||
concurrencyPolicy: "Replace" | ||
startingDeadlineSeconds: 0 | ||
workflowSpec: | ||
metadata: | ||
labels: | ||
workflows.argoproj.io/test: "true" | ||
podGC: | ||
strategy: OnPodCompletion | ||
entrypoint: sleep | ||
templates: | ||
- name: sleep | ||
container: | ||
image: alpine:latest | ||
command: [sh, -c, "sleep 120"] |
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,29 @@ | ||
package metrics | ||
|
||
import ( | ||
"context" | ||
|
||
wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1" | ||
"github.com/argoproj/argo-workflows/v3/util/telemetry" | ||
) | ||
|
||
const ( | ||
nameCronPolicy = `cronworkflows_concurrencypolicy_triggered` | ||
) | ||
|
||
func addCronWfPolicyCounter(_ context.Context, m *Metrics) error { | ||
return m.CreateInstrument(telemetry.Int64Counter, | ||
nameCronPolicy, | ||
"Total number of times CronWorkflow concurrencyPolicy has triggered", | ||
"{cronworkflow}", | ||
telemetry.WithAsBuiltIn(), | ||
) | ||
} | ||
|
||
func (m *Metrics) CronWfPolicy(ctx context.Context, name, namespace string, policy wfv1.ConcurrencyPolicy) { | ||
m.AddInt(ctx, nameCronPolicy, 1, telemetry.InstAttribs{ | ||
{Name: telemetry.AttribCronWFName, Value: name}, | ||
{Name: telemetry.AttribWorkflowNamespace, Value: namespace}, | ||
{Name: telemetry.AttribConcurrencyPolicy, Value: string(policy)}, | ||
}) | ||
} |
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