-
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 (#13497)
Signed-off-by: Alan Clucas <alan@clucas.org> Co-authored-by: Julie Vogelman <julievogelman0@gmail.com>
- 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