Skip to content

Commit 2b610f1

Browse files
authored
Emits billable action metric for UpdateWorkflowExecutionOptions; fixes action metric for StartWorkflowExecution (#7552)
1 parent d0b12cf commit 2b610f1

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

common/rpc/interceptor/telemetry.go

+7-13
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,20 @@ var (
7979
)
8080

8181
var (
82-
respondWorkflowTaskCompleted = "RespondWorkflowTaskCompleted"
83-
pollActivityTaskQueue = "PollActivityTaskQueue"
84-
startWorkflowExecution = "StartWorkflowExecution"
85-
executeMultiOperation = "ExecuteMultiOperation"
86-
queryWorkflow = "QueryWorkflow"
82+
respondWorkflowTaskCompleted = "RespondWorkflowTaskCompleted"
83+
pollActivityTaskQueue = "PollActivityTaskQueue"
84+
startWorkflowExecution = "StartWorkflowExecution"
85+
executeMultiOperation = "ExecuteMultiOperation"
86+
queryWorkflow = "QueryWorkflow"
87+
updateWorkflowExecutionOptions = "UpdateWorkflowExecutionOptions"
8788

8889
grpcActions = map[string]struct{}{
8990
startWorkflowExecution: {},
9091
executeMultiOperation: {},
9192
respondWorkflowTaskCompleted: {},
9293
pollActivityTaskQueue: {},
9394
queryWorkflow: {},
95+
updateWorkflowExecutionOptions: {},
9496
"RecordActivityTaskHeartbeat": {},
9597
"RecordActivityTaskHeartbeatById": {},
9698
"ResetWorkflowExecution": {},
@@ -255,14 +257,6 @@ func (ti *TelemetryInterceptor) emitActionMetric(
255257
}
256258

257259
switch methodName {
258-
case startWorkflowExecution:
259-
resp, ok := result.(*workflowservice.StartWorkflowExecutionResponse)
260-
if !ok {
261-
return
262-
}
263-
if resp.Started {
264-
metrics.ActionCounter.With(metricsHandler).Record(1, metrics.ActionType("grpc_"+methodName))
265-
}
266260
case executeMultiOperation:
267261
resp, ok := result.(*workflowservice.ExecuteMultiOperationResponse)
268262
if !ok {

common/rpc/interceptor/telemetry_test.go

+20-6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
protocolpb "go.temporal.io/api/protocol/v1"
3636
querypb "go.temporal.io/api/query/v1"
3737
"go.temporal.io/api/serviceerror"
38+
workflowpb "go.temporal.io/api/workflow/v1"
3839
"go.temporal.io/api/workflowservice/v1"
3940
"go.temporal.io/server/api/historyservice/v1"
4041
"go.temporal.io/server/common/api"
@@ -70,15 +71,10 @@ func TestEmitActionMetric(t *testing.T) {
7071
req any
7172
resp any
7273
}{
73-
{
74-
methodName: startWorkflow,
75-
fullName: api.WorkflowServicePrefix + startWorkflow,
76-
resp: &workflowservice.StartWorkflowExecutionResponse{Started: false},
77-
},
7874
{
7975
methodName: startWorkflow,
8076
fullName: api.WorkflowServicePrefix + startWorkflow,
81-
resp: &workflowservice.StartWorkflowExecutionResponse{Started: true},
77+
resp: &workflowservice.StartWorkflowExecutionResponse{},
8278
expectEmitMetrics: true,
8379
},
8480
{
@@ -216,6 +212,24 @@ func TestEmitActionMetric(t *testing.T) {
216212
},
217213
expectEmitMetrics: true,
218214
},
215+
{
216+
methodName: updateWorkflowExecutionOptions,
217+
fullName: api.WorkflowServicePrefix + updateWorkflowExecutionOptions,
218+
req: &workflowservice.UpdateWorkflowExecutionOptionsRequest{
219+
Namespace: "test-namespace",
220+
WorkflowExecution: &commonpb.WorkflowExecution{
221+
WorkflowId: "test-workflow-id",
222+
RunId: "test-run-id",
223+
},
224+
WorkflowExecutionOptions: &workflowpb.WorkflowExecutionOptions{
225+
VersioningOverride: &workflowpb.VersioningOverride{
226+
Behavior: enumspb.VERSIONING_BEHAVIOR_PINNED,
227+
PinnedVersion: "fake-version",
228+
},
229+
},
230+
},
231+
expectEmitMetrics: true,
232+
},
219233
{
220234
methodName: queryWorkflow,
221235
fullName: api.WorkflowServicePrefix + queryWorkflow,

0 commit comments

Comments
 (0)