Skip to content

Commit

Permalink
feat: add retry count value of custom metric (#11927)
Browse files Browse the repository at this point in the history
Signed-off-by: moonyoungCHAE <xpf_fl@naver.com>
  • Loading branch information
moonyoungCHAE committed Dec 14, 2023
1 parent 51ed591 commit dee7ec5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
19 changes: 10 additions & 9 deletions docs/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,16 @@ Note: These variables evaluate to a string type. If using advanced expressions,
When emitting custom metrics in a `template`, special variables are available that allow self-reference to the current
step.

| Variable | Description|
|----------|------------|
| `status` | Phase status of the metric-emitting template |
| `duration` | Duration of the metric-emitting template in seconds (only applicable in `Template`-level metrics, for `Workflow`-level use `workflow.duration`) |
| `exitCode` | Exit code of the metric-emitting template |
| `inputs.parameters.<NAME>` | Input parameter of the metric-emitting template |
| `outputs.parameters.<NAME>` | Output parameter of the metric-emitting template |
| `outputs.result` | Output result of the metric-emitting template |
| `resourcesDuration.{cpu,memory}` | Resources duration **in seconds**. Must be one of `resourcesDuration.cpu` or `resourcesDuration.memory`, if available. For more info, see the [Resource Duration](resource-duration.md) doc.|
| Variable | Description |
|----------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `status` | Phase status of the metric-emitting template |
| `duration` | Duration of the metric-emitting template in seconds (only applicable in `Template`-level metrics, for `Workflow`-level use `workflow.duration`) |
| `exitCode` | Exit code of the metric-emitting template |
| `inputs.parameters.<NAME>` | Input parameter of the metric-emitting template |
| `outputs.parameters.<NAME>` | Output parameter of the metric-emitting template |
| `outputs.result` | Output result of the metric-emitting template |
| `resourcesDuration.{cpu,memory}` | Resources duration **in seconds**. Must be one of `resourcesDuration.cpu` or `resourcesDuration.memory`, if available. For more info, see the [Resource Duration](resource-duration.md) doc. |
| `retries` | Retried count by retry strategy |

### Real-Time Metrics

Expand Down
5 changes: 5 additions & 0 deletions workflow/controller/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -595,6 +596,10 @@ func (woc *wfOperationCtx) prepareMetricScope(node *wfv1.NodeStatus) (map[string
}
}

if len(node.Children) != 0 {
localScope[common.LocalVarRetries] = strconv.Itoa(len(node.Children) - 1)
}

if node.Phase != "" {
localScope[common.LocalVarStatus] = string(node.Phase)
}
Expand Down

0 comments on commit dee7ec5

Please sign in to comment.