Skip to content

Commit

Permalink
Add action metrics for schedule and updates (#5101)
Browse files Browse the repository at this point in the history
<!-- Describe what has changed in this PR -->
**What changed?**
Add more action metrics for schedules and updates

<!-- Tell your future self why have you made these changes -->
**Why?**
Add more actions

<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
**How did you test it?**
eye_balls

<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
**Potential risks**
No

<!-- Is this PR a hotfix candidate or require that a notification be
sent to the broader community? (Yes/No) -->
**Is hotfix candidate?**
No
  • Loading branch information
yiminc authored and rodrigozhou committed Nov 13, 2023
1 parent 37da275 commit db23e86
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 35 deletions.
18 changes: 0 additions & 18 deletions common/metrics/metric_defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -651,18 +651,8 @@ const (
// OperatorDeleteNamespaceScope is the metric scope for operator.OperatorDeleteNamespace
OperatorDeleteNamespaceScope = "OperatorDeleteNamespace"

// FrontendStartWorkflowExecutionScope is the metric scope for frontend.StartWorkflowExecution
FrontendStartWorkflowExecutionScope = "StartWorkflowExecution"
// FrontendPollWorkflowTaskQueueScope is the metric scope for frontend.PollWorkflowTaskQueue
FrontendPollWorkflowTaskQueueScope = "PollWorkflowTaskQueue"
// FrontendPollActivityTaskQueueScope is the metric scope for frontend.PollActivityTaskQueue
FrontendPollActivityTaskQueueScope = "PollActivityTaskQueue"
// FrontendRecordActivityTaskHeartbeatScope is the metric scope for frontend.RecordActivityTaskHeartbeat
FrontendRecordActivityTaskHeartbeatScope = "RecordActivityTaskHeartbeat"
// FrontendRecordActivityTaskHeartbeatByIdScope is the metric scope for frontend.RecordActivityTaskHeartbeatById
FrontendRecordActivityTaskHeartbeatByIdScope = "RecordActivityTaskHeartbeatById"
// FrontendRespondWorkflowTaskCompletedScope is the metric scope for frontend.RespondWorkflowTaskCompleted
FrontendRespondWorkflowTaskCompletedScope = "RespondWorkflowTaskCompleted"
// FrontendRespondWorkflowTaskFailedScope is the metric scope for frontend.RespondWorkflowTaskFailed
FrontendRespondWorkflowTaskFailedScope = "RespondWorkflowTaskFailed"
// FrontendRespondQueryTaskCompletedScope is the metric scope for frontend.RespondQueryTaskCompleted
Expand All @@ -689,10 +679,6 @@ const (
FrontendGetWorkflowExecutionRawHistoryScope = "GetWorkflowExecutionRawHistory"
// FrontendPollForWorkflowExecutionRawHistoryScope is the metric scope for frontend.GetWorkflowExecutionRawHistory
FrontendPollForWorkflowExecutionRawHistoryScope = "PollForWorkflowExecutionRawHistory"
// FrontendSignalWorkflowExecutionScope is the metric scope for frontend.SignalWorkflowExecution
FrontendSignalWorkflowExecutionScope = "SignalWorkflowExecution"
// FrontendSignalWithStartWorkflowExecutionScope is the metric scope for frontend.SignalWithStartWorkflowExecution
FrontendSignalWithStartWorkflowExecutionScope = "SignalWithStartWorkflowExecution"
// FrontendTerminateWorkflowExecutionScope is the metric scope for frontend.TerminateWorkflowExecution
FrontendTerminateWorkflowExecutionScope = "TerminateWorkflowExecution"
// FrontendDeleteWorkflowExecutionScope is the metric scope for frontend.DeleteWorkflowExecution
Expand All @@ -719,8 +705,6 @@ const (
FrontendUpdateNamespaceScope = "UpdateNamespace"
// FrontendDeprecateNamespaceScope is the metric scope for frontend.DeprecateNamespace
FrontendDeprecateNamespaceScope = "DeprecateNamespace"
// FrontendQueryWorkflowScope is the metric scope for frontend.QueryWorkflow
FrontendQueryWorkflowScope = "QueryWorkflow"
// FrontendDescribeWorkflowExecutionScope is the metric scope for frontend.DescribeWorkflowExecution
FrontendDescribeWorkflowExecutionScope = "DescribeWorkflowExecution"
// FrontendDescribeTaskQueueScope is the metric scope for frontend.DescribeTaskQueue
Expand All @@ -731,8 +715,6 @@ const (
FrontendResetStickyTaskQueueScope = "ResetStickyTaskQueue"
// FrontendListNamespacesScope is the metric scope for frontend.ListNamespace
FrontendListNamespacesScope = "ListNamespaces"
// FrontendResetWorkflowExecutionScope is the metric scope for frontend.ResetWorkflowExecution
FrontendResetWorkflowExecutionScope = "ResetWorkflowExecution"
// FrontendGetSearchAttributesScope is the metric scope for frontend.GetSearchAttributes
FrontendGetSearchAttributesScope = "GetSearchAttributes"
// FrontendGetClusterInfoScope is the metric scope for frontend.GetClusterInfo
Expand Down
23 changes: 14 additions & 9 deletions common/rpc/interceptor/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,20 @@ var (
pollActivityTaskQueue = "PollActivityTaskQueue"

grpcActions = map[string]struct{}{
metrics.FrontendQueryWorkflowScope: {},
metrics.FrontendRecordActivityTaskHeartbeatScope: {},
metrics.FrontendRecordActivityTaskHeartbeatByIdScope: {},
metrics.FrontendResetWorkflowExecutionScope: {},
metrics.FrontendStartWorkflowExecutionScope: {},
metrics.FrontendSignalWorkflowExecutionScope: {},
metrics.FrontendSignalWithStartWorkflowExecutionScope: {},
metrics.FrontendRespondWorkflowTaskCompletedScope: {},
metrics.FrontendPollActivityTaskQueueScope: {},
"QueryWorkflow": {},
"RecordActivityTaskHeartbeat": {},
"RecordActivityTaskHeartbeatById": {},
"ResetWorkflowExecution": {},
"StartWorkflowExecution": {},
"SignalWorkflowExecution": {},
"SignalWithStartWorkflowExecution": {},
"RespondWorkflowTaskCompleted": {},
"PollActivityTaskQueue": {},
"CreateSchedule": {},
"UpdateSchedule": {},
"DeleteSchedule": {},
"PatchSchedule": {},
"UpdateWorkflowExecution": {},
}

commandActions = map[enums.CommandType]struct{}{
Expand Down
21 changes: 13 additions & 8 deletions common/rpc/interceptor/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ import (
"go.temporal.io/server/common/namespace"
)

const (
startWorkflow = "StartWorkflowExecution"
queryWorkflow = "QueryWorkflow"
)

func TestEmitActionMetric(t *testing.T) {
controller := gomock.NewController(t)
register := namespace.NewMockRegistry(controller)
Expand All @@ -48,18 +53,18 @@ func TestEmitActionMetric(t *testing.T) {
expectEmitMetrics bool
}{
{
metrics.FrontendQueryWorkflowScope,
api.WorkflowServicePrefix + metrics.FrontendQueryWorkflowScope,
queryWorkflow,
api.WorkflowServicePrefix + queryWorkflow,
true,
},
{
metrics.FrontendQueryWorkflowScope,
metrics.FrontendQueryWorkflowScope,
queryWorkflow,
api.AdminServicePrefix + queryWorkflow,
false,
},
{
metrics.MatchingClientAddWorkflowTaskScope,
api.WorkflowServicePrefix + metrics.FrontendQueryWorkflowScope,
api.WorkflowServicePrefix + queryWorkflow,
false,
},
}
Expand Down Expand Up @@ -98,9 +103,9 @@ func TestOperationOverwrite(t *testing.T) {
"OperatorDeleteNamespace",
},
{
metrics.FrontendStartWorkflowExecutionScope,
api.WorkflowServicePrefix + metrics.FrontendStartWorkflowExecutionScope,
metrics.FrontendStartWorkflowExecutionScope,
startWorkflow,
api.WorkflowServicePrefix + startWorkflow,
startWorkflow,
},
}

Expand Down

0 comments on commit db23e86

Please sign in to comment.