Skip to content

Commit 7b9e109

Browse files
authored
Add WorkflowTypeName to completion metrics (#7756)
## What changed? Added the `WorkflowTypeName` as a label on completion metrics. ## Why? Being able to track metrics (`operation="CompletionStats"`) for completion and failures (`workflow_success`, `workflow_failed`, ...) per `WorkflowTypeName`. ## How did you test it? - [x] built - [x] run locally and tested manually - [ ] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) ## Potential risks In cases where the `WorkflowTypeName` is automatically generated or in general not suitable for usage as a label, it could lead to high cardinality of the metrics.
1 parent 7764cbd commit 7b9e109

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

service/history/workflow/metrics.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,14 @@ func emitWorkflowCompletionStats(
7979
namespace namespace.Name,
8080
namespaceState string,
8181
taskQueue string,
82+
workflowTypeName string,
8283
status enumspb.WorkflowExecutionStatus,
8384
config *configs.Config,
8485
) {
8586
handler := GetPerTaskQueueFamilyScope(metricsHandler, namespace, taskQueue, config,
8687
metrics.OperationTag(metrics.WorkflowCompletionStatsScope),
8788
metrics.NamespaceStateTag(namespaceState),
89+
metrics.WorkflowTypeTag(workflowTypeName),
8890
)
8991

9092
switch status {

service/history/workflow/transaction_impl.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ import (
1818

1919
type (
2020
completionMetric struct {
21-
initialized bool
22-
taskQueue string
23-
namespaceState string
24-
status enumspb.WorkflowExecutionStatus
21+
initialized bool
22+
taskQueue string
23+
namespaceState string
24+
workflowTypeName string
25+
status enumspb.WorkflowExecutionStatus
2526
}
2627
TransactionImpl struct {
2728
shard historyi.ShardContext
@@ -680,10 +681,11 @@ func snapshotToCompletionMetric(
680681
return completionMetric{initialized: false}
681682
}
682683
return completionMetric{
683-
initialized: true,
684-
taskQueue: workflowSnapshot.ExecutionInfo.TaskQueue,
685-
namespaceState: namespaceState,
686-
status: workflowSnapshot.ExecutionState.Status,
684+
initialized: true,
685+
taskQueue: workflowSnapshot.ExecutionInfo.TaskQueue,
686+
namespaceState: namespaceState,
687+
workflowTypeName: workflowSnapshot.ExecutionInfo.WorkflowTypeName,
688+
status: workflowSnapshot.ExecutionState.Status,
687689
}
688690
}
689691

@@ -695,10 +697,11 @@ func mutationToCompletionMetric(
695697
return completionMetric{initialized: false}
696698
}
697699
return completionMetric{
698-
initialized: true,
699-
taskQueue: workflowMutation.ExecutionInfo.TaskQueue,
700-
namespaceState: namespaceState,
701-
status: workflowMutation.ExecutionState.Status,
700+
initialized: true,
701+
taskQueue: workflowMutation.ExecutionInfo.TaskQueue,
702+
namespaceState: namespaceState,
703+
workflowTypeName: workflowMutation.ExecutionInfo.WorkflowTypeName,
704+
status: workflowMutation.ExecutionState.Status,
702705
}
703706
}
704707

@@ -719,6 +722,7 @@ func emitCompletionMetrics(
719722
namespaceName,
720723
completionMetric.namespaceState,
721724
completionMetric.taskQueue,
725+
completionMetric.workflowTypeName,
722726
completionMetric.status,
723727
shardContext.GetConfig(),
724728
)

0 commit comments

Comments
 (0)