Skip to content

Commit

Permalink
Record actions counter on nexus related commands (temporalio#6421)
Browse files Browse the repository at this point in the history
## What changed?

Increment actions metric on `ScheduleNexusOperation` and
`RequestCancelNexusOperation` commands.

## Why?

Keep in line with other billable actions.

## How did you test it?

Added unit test.
  • Loading branch information
bergundy authored Aug 21, 2024
1 parent 5c4b82c commit 454c072
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions common/rpc/interceptor/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ var (
enums.COMMAND_TYPE_UPSERT_WORKFLOW_SEARCH_ATTRIBUTES: {},
enums.COMMAND_TYPE_MODIFY_WORKFLOW_PROPERTIES: {},
enums.COMMAND_TYPE_CONTINUE_AS_NEW_WORKFLOW_EXECUTION: {},
enums.COMMAND_TYPE_SCHEDULE_NEXUS_OPERATION: {},
enums.COMMAND_TYPE_REQUEST_CANCEL_NEXUS_OPERATION: {},
}
)

Expand Down
17 changes: 15 additions & 2 deletions common/rpc/interceptor/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"

commandpb "go.temporal.io/api/command/v1"
commonpb "go.temporal.io/api/common/v1"
enumspb "go.temporal.io/api/enums/v1"
protocolpb "go.temporal.io/api/protocol/v1"
Expand Down Expand Up @@ -111,6 +112,18 @@ func TestEmitActionMetric(t *testing.T) {
},
expectEmitMetrics: true,
},
{
methodName: metrics.HistoryRespondWorkflowTaskCompletedScope,
fullName: api.WorkflowServicePrefix + "RespondWorkflowTaskCompleted",
req: &workflowservice.RespondWorkflowTaskCompletedRequest{
Commands: []*commandpb.Command{
{
CommandType: enumspb.COMMAND_TYPE_SCHEDULE_NEXUS_OPERATION,
},
},
},
expectEmitMetrics: true,
},
{
methodName: metrics.HistoryRespondWorkflowTaskCompletedScope,
fullName: api.WorkflowServicePrefix + "RespondWorkflowTaskCompleted",
Expand Down Expand Up @@ -141,9 +154,9 @@ func TestEmitActionMetric(t *testing.T) {
for _, tt := range testCases {
t.Run(tt.methodName, func(t *testing.T) {
if tt.expectEmitMetrics {
metricsHandler.EXPECT().Counter(gomock.Any()).Return(metrics.NoopCounterMetricFunc).Times(1)
metricsHandler.EXPECT().Counter(metrics.ActionCounter.Name()).Return(metrics.NoopCounterMetricFunc).Times(1)
} else {
metricsHandler.EXPECT().Counter(gomock.Any()).Return(metrics.NoopCounterMetricFunc).Times(0)
metricsHandler.EXPECT().Counter(metrics.ActionCounter.Name()).Return(metrics.NoopCounterMetricFunc).Times(0)
}
telemetry.emitActionMetric(tt.methodName, tt.fullName, tt.req, metricsHandler, tt.resp)
})
Expand Down

0 comments on commit 454c072

Please sign in to comment.