package metered

// Code generated by gowrap. DO NOT EDIT.
// template: ../../templates/metered.tmpl
// gowrap: http://github.com/hexdigest/gowrap

import (
	"context"

	"go.uber.org/yarpc"

	"github.com/uber/cadence/client/frontend"
	"github.com/uber/cadence/common/metrics"
	"github.com/uber/cadence/common/types"
)

// frontendClient implements frontend.Client interface instrumented with retries
type frontendClient struct {
	client        frontend.Client
	metricsClient metrics.Client
}

// NewFrontendClient creates a new instance of frontendClient with retry policy
func NewFrontendClient(client frontend.Client, metricsClient metrics.Client) frontend.Client {
	return &frontendClient{
		client:        client,
		metricsClient: metricsClient,
	}
}

func (c *frontendClient) CountWorkflowExecutions(ctx context.Context, cp1 *types.CountWorkflowExecutionsRequest, p1 ...yarpc.CallOption) (cp2 *types.CountWorkflowExecutionsResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientCountWorkflowExecutionsScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientCountWorkflowExecutionsScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	cp2, err = c.client.CountWorkflowExecutions(ctx, cp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return cp2, err
}

func (c *frontendClient) DeleteDomain(ctx context.Context, dp1 *types.DeleteDomainRequest, p1 ...yarpc.CallOption) (err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientDeleteDomainScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientDeleteDomainScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	err = c.client.DeleteDomain(ctx, dp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return err
}

func (c *frontendClient) DeprecateDomain(ctx context.Context, dp1 *types.DeprecateDomainRequest, p1 ...yarpc.CallOption) (err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientDeprecateDomainScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientDeprecateDomainScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	err = c.client.DeprecateDomain(ctx, dp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return err
}

func (c *frontendClient) DescribeDomain(ctx context.Context, dp1 *types.DescribeDomainRequest, p1 ...yarpc.CallOption) (dp2 *types.DescribeDomainResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientDescribeDomainScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientDescribeDomainScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	dp2, err = c.client.DescribeDomain(ctx, dp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return dp2, err
}

func (c *frontendClient) DescribeTaskList(ctx context.Context, dp1 *types.DescribeTaskListRequest, p1 ...yarpc.CallOption) (dp2 *types.DescribeTaskListResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientDescribeTaskListScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientDescribeTaskListScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	dp2, err = c.client.DescribeTaskList(ctx, dp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return dp2, err
}

func (c *frontendClient) DescribeWorkflowExecution(ctx context.Context, dp1 *types.DescribeWorkflowExecutionRequest, p1 ...yarpc.CallOption) (dp2 *types.DescribeWorkflowExecutionResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientDescribeWorkflowExecutionScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientDescribeWorkflowExecutionScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	dp2, err = c.client.DescribeWorkflowExecution(ctx, dp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return dp2, err
}

func (c *frontendClient) DiagnoseWorkflowExecution(ctx context.Context, dp1 *types.DiagnoseWorkflowExecutionRequest, p1 ...yarpc.CallOption) (dp2 *types.DiagnoseWorkflowExecutionResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientDiagnoseWorkflowExecutionScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientDiagnoseWorkflowExecutionScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	dp2, err = c.client.DiagnoseWorkflowExecution(ctx, dp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return dp2, err
}

func (c *frontendClient) FailoverDomain(ctx context.Context, fp1 *types.FailoverDomainRequest, p1 ...yarpc.CallOption) (fp2 *types.FailoverDomainResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientFailoverDomainScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientFailoverDomainScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	fp2, err = c.client.FailoverDomain(ctx, fp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return fp2, err
}

func (c *frontendClient) GetClusterInfo(ctx context.Context, p1 ...yarpc.CallOption) (cp1 *types.ClusterInfo, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientGetClusterInfoScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientGetClusterInfoScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	cp1, err = c.client.GetClusterInfo(ctx, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return cp1, err
}

func (c *frontendClient) GetSearchAttributes(ctx context.Context, p1 ...yarpc.CallOption) (gp1 *types.GetSearchAttributesResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientGetSearchAttributesScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientGetSearchAttributesScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	gp1, err = c.client.GetSearchAttributes(ctx, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return gp1, err
}

func (c *frontendClient) GetTaskListsByDomain(ctx context.Context, gp1 *types.GetTaskListsByDomainRequest, p1 ...yarpc.CallOption) (gp2 *types.GetTaskListsByDomainResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientGetTaskListsByDomainScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientGetTaskListsByDomainScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	gp2, err = c.client.GetTaskListsByDomain(ctx, gp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return gp2, err
}

func (c *frontendClient) GetWorkflowExecutionHistory(ctx context.Context, gp1 *types.GetWorkflowExecutionHistoryRequest, p1 ...yarpc.CallOption) (gp2 *types.GetWorkflowExecutionHistoryResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientGetWorkflowExecutionHistoryScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientGetWorkflowExecutionHistoryScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	gp2, err = c.client.GetWorkflowExecutionHistory(ctx, gp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return gp2, err
}

func (c *frontendClient) ListArchivedWorkflowExecutions(ctx context.Context, lp1 *types.ListArchivedWorkflowExecutionsRequest, p1 ...yarpc.CallOption) (lp2 *types.ListArchivedWorkflowExecutionsResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientListArchivedWorkflowExecutionsScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientListArchivedWorkflowExecutionsScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	lp2, err = c.client.ListArchivedWorkflowExecutions(ctx, lp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return lp2, err
}

func (c *frontendClient) ListClosedWorkflowExecutions(ctx context.Context, lp1 *types.ListClosedWorkflowExecutionsRequest, p1 ...yarpc.CallOption) (lp2 *types.ListClosedWorkflowExecutionsResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientListClosedWorkflowExecutionsScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientListClosedWorkflowExecutionsScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	lp2, err = c.client.ListClosedWorkflowExecutions(ctx, lp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return lp2, err
}

func (c *frontendClient) ListDomains(ctx context.Context, lp1 *types.ListDomainsRequest, p1 ...yarpc.CallOption) (lp2 *types.ListDomainsResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientListDomainsScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientListDomainsScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	lp2, err = c.client.ListDomains(ctx, lp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return lp2, err
}

func (c *frontendClient) ListOpenWorkflowExecutions(ctx context.Context, lp1 *types.ListOpenWorkflowExecutionsRequest, p1 ...yarpc.CallOption) (lp2 *types.ListOpenWorkflowExecutionsResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientListOpenWorkflowExecutionsScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientListOpenWorkflowExecutionsScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	lp2, err = c.client.ListOpenWorkflowExecutions(ctx, lp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return lp2, err
}

func (c *frontendClient) ListTaskListPartitions(ctx context.Context, lp1 *types.ListTaskListPartitionsRequest, p1 ...yarpc.CallOption) (lp2 *types.ListTaskListPartitionsResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientListTaskListPartitionsScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientListTaskListPartitionsScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	lp2, err = c.client.ListTaskListPartitions(ctx, lp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return lp2, err
}

func (c *frontendClient) ListWorkflowExecutions(ctx context.Context, lp1 *types.ListWorkflowExecutionsRequest, p1 ...yarpc.CallOption) (lp2 *types.ListWorkflowExecutionsResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientListWorkflowExecutionsScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientListWorkflowExecutionsScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	lp2, err = c.client.ListWorkflowExecutions(ctx, lp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return lp2, err
}

func (c *frontendClient) PollForActivityTask(ctx context.Context, pp1 *types.PollForActivityTaskRequest, p1 ...yarpc.CallOption) (pp2 *types.PollForActivityTaskResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientPollForActivityTaskScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientPollForActivityTaskScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	pp2, err = c.client.PollForActivityTask(ctx, pp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return pp2, err
}

func (c *frontendClient) PollForDecisionTask(ctx context.Context, pp1 *types.PollForDecisionTaskRequest, p1 ...yarpc.CallOption) (pp2 *types.PollForDecisionTaskResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientPollForDecisionTaskScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientPollForDecisionTaskScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	pp2, err = c.client.PollForDecisionTask(ctx, pp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return pp2, err
}

func (c *frontendClient) QueryWorkflow(ctx context.Context, qp1 *types.QueryWorkflowRequest, p1 ...yarpc.CallOption) (qp2 *types.QueryWorkflowResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientQueryWorkflowScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientQueryWorkflowScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	qp2, err = c.client.QueryWorkflow(ctx, qp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return qp2, err
}

func (c *frontendClient) RecordActivityTaskHeartbeat(ctx context.Context, rp1 *types.RecordActivityTaskHeartbeatRequest, p1 ...yarpc.CallOption) (rp2 *types.RecordActivityTaskHeartbeatResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientRecordActivityTaskHeartbeatScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientRecordActivityTaskHeartbeatScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	rp2, err = c.client.RecordActivityTaskHeartbeat(ctx, rp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return rp2, err
}

func (c *frontendClient) RecordActivityTaskHeartbeatByID(ctx context.Context, rp1 *types.RecordActivityTaskHeartbeatByIDRequest, p1 ...yarpc.CallOption) (rp2 *types.RecordActivityTaskHeartbeatResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientRecordActivityTaskHeartbeatByIDScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientRecordActivityTaskHeartbeatByIDScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	rp2, err = c.client.RecordActivityTaskHeartbeatByID(ctx, rp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return rp2, err
}

func (c *frontendClient) RefreshWorkflowTasks(ctx context.Context, rp1 *types.RefreshWorkflowTasksRequest, p1 ...yarpc.CallOption) (err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientRefreshWorkflowTasksScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientRefreshWorkflowTasksScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	err = c.client.RefreshWorkflowTasks(ctx, rp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return err
}

func (c *frontendClient) RegisterDomain(ctx context.Context, rp1 *types.RegisterDomainRequest, p1 ...yarpc.CallOption) (err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientRegisterDomainScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientRegisterDomainScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	err = c.client.RegisterDomain(ctx, rp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return err
}

func (c *frontendClient) RequestCancelWorkflowExecution(ctx context.Context, rp1 *types.RequestCancelWorkflowExecutionRequest, p1 ...yarpc.CallOption) (err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientRequestCancelWorkflowExecutionScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientRequestCancelWorkflowExecutionScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	err = c.client.RequestCancelWorkflowExecution(ctx, rp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return err
}

func (c *frontendClient) ResetStickyTaskList(ctx context.Context, rp1 *types.ResetStickyTaskListRequest, p1 ...yarpc.CallOption) (rp2 *types.ResetStickyTaskListResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientResetStickyTaskListScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientResetStickyTaskListScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	rp2, err = c.client.ResetStickyTaskList(ctx, rp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return rp2, err
}

func (c *frontendClient) ResetWorkflowExecution(ctx context.Context, rp1 *types.ResetWorkflowExecutionRequest, p1 ...yarpc.CallOption) (rp2 *types.ResetWorkflowExecutionResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientResetWorkflowExecutionScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientResetWorkflowExecutionScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	rp2, err = c.client.ResetWorkflowExecution(ctx, rp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return rp2, err
}

func (c *frontendClient) RespondActivityTaskCanceled(ctx context.Context, rp1 *types.RespondActivityTaskCanceledRequest, p1 ...yarpc.CallOption) (err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientRespondActivityTaskCanceledScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientRespondActivityTaskCanceledScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	err = c.client.RespondActivityTaskCanceled(ctx, rp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return err
}

func (c *frontendClient) RespondActivityTaskCanceledByID(ctx context.Context, rp1 *types.RespondActivityTaskCanceledByIDRequest, p1 ...yarpc.CallOption) (err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientRespondActivityTaskCanceledByIDScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientRespondActivityTaskCanceledByIDScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	err = c.client.RespondActivityTaskCanceledByID(ctx, rp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return err
}

func (c *frontendClient) RespondActivityTaskCompleted(ctx context.Context, rp1 *types.RespondActivityTaskCompletedRequest, p1 ...yarpc.CallOption) (err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientRespondActivityTaskCompletedScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientRespondActivityTaskCompletedScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	err = c.client.RespondActivityTaskCompleted(ctx, rp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return err
}

func (c *frontendClient) RespondActivityTaskCompletedByID(ctx context.Context, rp1 *types.RespondActivityTaskCompletedByIDRequest, p1 ...yarpc.CallOption) (err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientRespondActivityTaskCompletedByIDScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientRespondActivityTaskCompletedByIDScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	err = c.client.RespondActivityTaskCompletedByID(ctx, rp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return err
}

func (c *frontendClient) RespondActivityTaskFailed(ctx context.Context, rp1 *types.RespondActivityTaskFailedRequest, p1 ...yarpc.CallOption) (err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientRespondActivityTaskFailedScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientRespondActivityTaskFailedScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	err = c.client.RespondActivityTaskFailed(ctx, rp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return err
}

func (c *frontendClient) RespondActivityTaskFailedByID(ctx context.Context, rp1 *types.RespondActivityTaskFailedByIDRequest, p1 ...yarpc.CallOption) (err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientRespondActivityTaskFailedByIDScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientRespondActivityTaskFailedByIDScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	err = c.client.RespondActivityTaskFailedByID(ctx, rp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return err
}

func (c *frontendClient) RespondDecisionTaskCompleted(ctx context.Context, rp1 *types.RespondDecisionTaskCompletedRequest, p1 ...yarpc.CallOption) (rp2 *types.RespondDecisionTaskCompletedResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientRespondDecisionTaskCompletedScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientRespondDecisionTaskCompletedScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	rp2, err = c.client.RespondDecisionTaskCompleted(ctx, rp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return rp2, err
}

func (c *frontendClient) RespondDecisionTaskFailed(ctx context.Context, rp1 *types.RespondDecisionTaskFailedRequest, p1 ...yarpc.CallOption) (err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientRespondDecisionTaskFailedScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientRespondDecisionTaskFailedScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	err = c.client.RespondDecisionTaskFailed(ctx, rp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return err
}

func (c *frontendClient) RespondQueryTaskCompleted(ctx context.Context, rp1 *types.RespondQueryTaskCompletedRequest, p1 ...yarpc.CallOption) (err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientRespondQueryTaskCompletedScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientRespondQueryTaskCompletedScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	err = c.client.RespondQueryTaskCompleted(ctx, rp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return err
}

func (c *frontendClient) RestartWorkflowExecution(ctx context.Context, rp1 *types.RestartWorkflowExecutionRequest, p1 ...yarpc.CallOption) (rp2 *types.RestartWorkflowExecutionResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientRestartWorkflowExecutionScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientRestartWorkflowExecutionScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	rp2, err = c.client.RestartWorkflowExecution(ctx, rp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return rp2, err
}

func (c *frontendClient) ScanWorkflowExecutions(ctx context.Context, lp1 *types.ListWorkflowExecutionsRequest, p1 ...yarpc.CallOption) (lp2 *types.ListWorkflowExecutionsResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientScanWorkflowExecutionsScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientScanWorkflowExecutionsScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	lp2, err = c.client.ScanWorkflowExecutions(ctx, lp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return lp2, err
}

func (c *frontendClient) SignalWithStartWorkflowExecution(ctx context.Context, sp1 *types.SignalWithStartWorkflowExecutionRequest, p1 ...yarpc.CallOption) (sp2 *types.StartWorkflowExecutionResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientSignalWithStartWorkflowExecutionScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientSignalWithStartWorkflowExecutionScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	sp2, err = c.client.SignalWithStartWorkflowExecution(ctx, sp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return sp2, err
}

func (c *frontendClient) SignalWithStartWorkflowExecutionAsync(ctx context.Context, sp1 *types.SignalWithStartWorkflowExecutionAsyncRequest, p1 ...yarpc.CallOption) (sp2 *types.SignalWithStartWorkflowExecutionAsyncResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientSignalWithStartWorkflowExecutionAsyncScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientSignalWithStartWorkflowExecutionAsyncScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	sp2, err = c.client.SignalWithStartWorkflowExecutionAsync(ctx, sp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return sp2, err
}

func (c *frontendClient) SignalWorkflowExecution(ctx context.Context, sp1 *types.SignalWorkflowExecutionRequest, p1 ...yarpc.CallOption) (err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientSignalWorkflowExecutionScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientSignalWorkflowExecutionScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	err = c.client.SignalWorkflowExecution(ctx, sp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return err
}

func (c *frontendClient) StartWorkflowExecution(ctx context.Context, sp1 *types.StartWorkflowExecutionRequest, p1 ...yarpc.CallOption) (sp2 *types.StartWorkflowExecutionResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientStartWorkflowExecutionScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientStartWorkflowExecutionScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	sp2, err = c.client.StartWorkflowExecution(ctx, sp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return sp2, err
}

func (c *frontendClient) StartWorkflowExecutionAsync(ctx context.Context, sp1 *types.StartWorkflowExecutionAsyncRequest, p1 ...yarpc.CallOption) (sp2 *types.StartWorkflowExecutionAsyncResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientStartWorkflowExecutionAsyncScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientStartWorkflowExecutionAsyncScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	sp2, err = c.client.StartWorkflowExecutionAsync(ctx, sp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return sp2, err
}

func (c *frontendClient) TerminateWorkflowExecution(ctx context.Context, tp1 *types.TerminateWorkflowExecutionRequest, p1 ...yarpc.CallOption) (err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientTerminateWorkflowExecutionScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientTerminateWorkflowExecutionScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	err = c.client.TerminateWorkflowExecution(ctx, tp1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return err
}

func (c *frontendClient) UpdateDomain(ctx context.Context, up1 *types.UpdateDomainRequest, p1 ...yarpc.CallOption) (up2 *types.UpdateDomainResponse, err error) {
	retryCount := getRetryCountFromContext(ctx)

	var scope metrics.Scope
	if retryCount == -1 {
		scope = c.metricsClient.Scope(metrics.FrontendClientUpdateDomainScope)
	} else {
		scope = c.metricsClient.Scope(metrics.FrontendClientUpdateDomainScope, metrics.IsRetryTag(retryCount > 0))
	}

	scope.IncCounter(metrics.CadenceClientRequests)

	sw := scope.StartTimer(metrics.CadenceClientLatency)
	up2, err = c.client.UpdateDomain(ctx, up1, p1...)
	sw.Stop()

	if err != nil {
		scope.IncCounter(metrics.CadenceClientFailures)
	}
	return up2, err
}
