Skip to content

Commit

Permalink
fix error logging for history client (#2472)
Browse files Browse the repository at this point in the history
  • Loading branch information
yiminc authored Feb 6, 2022
1 parent b2c7ee1 commit 16871d7
Showing 1 changed file with 102 additions and 34 deletions.
136 changes: 102 additions & 34 deletions client/history/metricClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ func (c *metricClient) StartWorkflowExecution(
) (_ *historyservice.StartWorkflowExecutionResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientStartWorkflowExecutionScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.StartWorkflowExecution(context, request, opts...)
}
Expand Down Expand Up @@ -125,7 +127,9 @@ func (c *metricClient) GetMutableState(
) (_ *historyservice.GetMutableStateResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientGetMutableStateScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.GetMutableState(context, request, opts...)
}
Expand All @@ -137,7 +141,9 @@ func (c *metricClient) PollMutableState(
) (_ *historyservice.PollMutableStateResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientPollMutableStateScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.PollMutableState(context, request, opts...)
}
Expand All @@ -149,7 +155,9 @@ func (c *metricClient) ResetStickyTaskQueue(
) (_ *historyservice.ResetStickyTaskQueueResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientResetStickyTaskQueueScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.ResetStickyTaskQueue(context, request, opts...)
}
Expand All @@ -161,7 +169,9 @@ func (c *metricClient) DescribeWorkflowExecution(
) (_ *historyservice.DescribeWorkflowExecutionResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientDescribeWorkflowExecutionScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.DescribeWorkflowExecution(context, request, opts...)
}
Expand All @@ -173,7 +183,9 @@ func (c *metricClient) RecordWorkflowTaskStarted(
) (_ *historyservice.RecordWorkflowTaskStartedResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientRecordWorkflowTaskStartedScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.RecordWorkflowTaskStarted(context, request, opts...)
}
Expand All @@ -185,7 +197,9 @@ func (c *metricClient) RecordActivityTaskStarted(
) (_ *historyservice.RecordActivityTaskStartedResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientRecordActivityTaskStartedScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.RecordActivityTaskStarted(context, request, opts...)
}
Expand All @@ -197,7 +211,9 @@ func (c *metricClient) RespondWorkflowTaskCompleted(
) (_ *historyservice.RespondWorkflowTaskCompletedResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientRespondWorkflowTaskCompletedScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.RespondWorkflowTaskCompleted(context, request, opts...)
}
Expand All @@ -209,7 +225,9 @@ func (c *metricClient) RespondWorkflowTaskFailed(
) (_ *historyservice.RespondWorkflowTaskFailedResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientRespondWorkflowTaskFailedScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.RespondWorkflowTaskFailed(context, request, opts...)
}
Expand All @@ -221,7 +239,9 @@ func (c *metricClient) RespondActivityTaskCompleted(
) (_ *historyservice.RespondActivityTaskCompletedResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientRespondActivityTaskCompletedScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.RespondActivityTaskCompleted(context, request, opts...)
}
Expand All @@ -233,7 +253,9 @@ func (c *metricClient) RespondActivityTaskFailed(
) (_ *historyservice.RespondActivityTaskFailedResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientRespondActivityTaskFailedScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.RespondActivityTaskFailed(context, request, opts...)
}
Expand All @@ -245,7 +267,9 @@ func (c *metricClient) RespondActivityTaskCanceled(
) (_ *historyservice.RespondActivityTaskCanceledResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientRespondActivityTaskCanceledScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.RespondActivityTaskCanceled(context, request, opts...)
}
Expand All @@ -257,7 +281,9 @@ func (c *metricClient) RecordActivityTaskHeartbeat(
) (_ *historyservice.RecordActivityTaskHeartbeatResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientRecordActivityTaskHeartbeatScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.RecordActivityTaskHeartbeat(context, request, opts...)
}
Expand All @@ -269,7 +295,9 @@ func (c *metricClient) RequestCancelWorkflowExecution(
) (_ *historyservice.RequestCancelWorkflowExecutionResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientRequestCancelWorkflowExecutionScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.RequestCancelWorkflowExecution(context, request, opts...)
}
Expand All @@ -281,7 +309,9 @@ func (c *metricClient) SignalWorkflowExecution(
) (_ *historyservice.SignalWorkflowExecutionResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientSignalWorkflowExecutionScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.SignalWorkflowExecution(context, request, opts...)
}
Expand All @@ -293,7 +323,9 @@ func (c *metricClient) SignalWithStartWorkflowExecution(
) (_ *historyservice.SignalWithStartWorkflowExecutionResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientSignalWithStartWorkflowExecutionScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.SignalWithStartWorkflowExecution(context, request, opts...)
}
Expand All @@ -305,7 +337,9 @@ func (c *metricClient) RemoveSignalMutableState(
) (_ *historyservice.RemoveSignalMutableStateResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientRemoveSignalMutableStateScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.RemoveSignalMutableState(context, request, opts...)
}
Expand All @@ -317,7 +351,9 @@ func (c *metricClient) TerminateWorkflowExecution(
) (_ *historyservice.TerminateWorkflowExecutionResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientTerminateWorkflowExecutionScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.TerminateWorkflowExecution(context, request, opts...)
}
Expand Down Expand Up @@ -346,7 +382,9 @@ func (c *metricClient) ResetWorkflowExecution(
) (_ *historyservice.ResetWorkflowExecutionResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientResetWorkflowExecutionScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.ResetWorkflowExecution(context, request, opts...)
}
Expand All @@ -358,7 +396,9 @@ func (c *metricClient) ScheduleWorkflowTask(
) (_ *historyservice.ScheduleWorkflowTaskResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientScheduleWorkflowTaskScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.ScheduleWorkflowTask(context, request, opts...)
}
Expand All @@ -370,7 +410,9 @@ func (c *metricClient) RecordChildExecutionCompleted(
) (_ *historyservice.RecordChildExecutionCompletedResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientRecordChildExecutionCompletedScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.RecordChildExecutionCompleted(context, request, opts...)
}
Expand All @@ -382,7 +424,9 @@ func (c *metricClient) ReplicateEventsV2(
) (_ *historyservice.ReplicateEventsV2Response, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientReplicateEventsV2Scope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.ReplicateEventsV2(context, request, opts...)
}
Expand All @@ -394,7 +438,9 @@ func (c *metricClient) SyncShardStatus(
) (_ *historyservice.SyncShardStatusResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientSyncShardStatusScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.SyncShardStatus(context, request, opts...)
}
Expand All @@ -406,7 +452,9 @@ func (c *metricClient) SyncActivity(
) (_ *historyservice.SyncActivityResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientSyncActivityScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.SyncActivity(context, request, opts...)
}
Expand All @@ -418,7 +466,9 @@ func (c *metricClient) GetReplicationMessages(
) (_ *historyservice.GetReplicationMessagesResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientGetReplicationTasksScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.GetReplicationMessages(context, request, opts...)
}
Expand All @@ -430,7 +480,9 @@ func (c *metricClient) GetDLQReplicationMessages(
) (_ *historyservice.GetDLQReplicationMessagesResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientGetDLQReplicationTasksScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.GetDLQReplicationMessages(context, request, opts...)
}
Expand All @@ -442,7 +494,9 @@ func (c *metricClient) QueryWorkflow(
) (_ *historyservice.QueryWorkflowResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientQueryWorkflowScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.QueryWorkflow(context, request, opts...)
}
Expand All @@ -454,7 +508,9 @@ func (c *metricClient) ReapplyEvents(
) (_ *historyservice.ReapplyEventsResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientReapplyEventsScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.ReapplyEvents(context, request, opts...)
}
Expand All @@ -466,7 +522,9 @@ func (c *metricClient) GetDLQMessages(
) (_ *historyservice.GetDLQMessagesResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientGetDLQMessagesScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.GetDLQMessages(ctx, request, opts...)
}
Expand All @@ -478,7 +536,9 @@ func (c *metricClient) PurgeDLQMessages(
) (_ *historyservice.PurgeDLQMessagesResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientPurgeDLQMessagesScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.PurgeDLQMessages(ctx, request, opts...)
}
Expand All @@ -490,7 +550,9 @@ func (c *metricClient) MergeDLQMessages(
) (_ *historyservice.MergeDLQMessagesResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientMergeDLQMessagesScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.MergeDLQMessages(ctx, request, opts...)
}
Expand All @@ -502,7 +564,9 @@ func (c *metricClient) RefreshWorkflowTasks(
) (_ *historyservice.RefreshWorkflowTasksResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientRefreshWorkflowTasksScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.RefreshWorkflowTasks(ctx, request, opts...)
}
Expand All @@ -514,7 +578,9 @@ func (c *metricClient) GenerateLastHistoryReplicationTasks(
) (_ *historyservice.GenerateLastHistoryReplicationTasksResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientGenerateLastHistoryReplicationTasksScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.GenerateLastHistoryReplicationTasks(ctx, request, opts...)
}
Expand All @@ -526,7 +592,9 @@ func (c *metricClient) GetReplicationStatus(
) (_ *historyservice.GetReplicationStatusResponse, retError error) {

scope, stopwatch := c.startMetricsRecording(metrics.HistoryClientGetReplicationStatusScope)
defer c.finishMetricsRecording(scope, stopwatch, retError)
defer func() {
c.finishMetricsRecording(scope, stopwatch, retError)
}()

return c.client.GetReplicationStatus(ctx, request, opts...)
}
Expand Down

0 comments on commit 16871d7

Please sign in to comment.