package metered

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

import (
	"context"

	"github.com/uber/cadence/common/config"
	"github.com/uber/cadence/common/dynamicconfig/dynamicproperties"
	"github.com/uber/cadence/common/log"
	"github.com/uber/cadence/common/log/tag"
	"github.com/uber/cadence/common/metrics"
	"github.com/uber/cadence/common/persistence"
	"github.com/uber/cadence/common/types"
)

// meteredExecutionManager implements persistence.ExecutionManager interface instrumented with rate limiter.
type meteredExecutionManager struct {
	base
	wrapped persistence.ExecutionManager
}

// NewExecutionManager creates a new instance of ExecutionManager with ratelimiter.
func NewExecutionManager(
	wrapped persistence.ExecutionManager,
	metricClient metrics.Client,
	logger log.Logger,
	cfg *config.Persistence,
	sampleLoggingRate dynamicproperties.IntPropertyFn,
	enableShardIDMetrics dynamicproperties.BoolPropertyFn,
) persistence.ExecutionManager {
	return &meteredExecutionManager{
		wrapped: wrapped,
		base: base{
			metricClient:                  metricClient,
			logger:                        logger.WithTags(tag.ShardID(wrapped.GetShardID())),
			enableLatencyHistogramMetrics: cfg.EnablePersistenceLatencyHistogramMetrics,
			sampleLoggingRate:             sampleLoggingRate,
			enableShardIDMetrics:          enableShardIDMetrics,
		},
	}
}

func (c *meteredExecutionManager) Close() {
	c.wrapped.Close()
	return
}

func (c *meteredExecutionManager) CompleteHistoryTask(ctx context.Context, request *persistence.CompleteHistoryTaskRequest) (err error) {
	op := func() error {
		err = c.wrapped.CompleteHistoryTask(ctx, request)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(request); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(request)...)
		c.logger.SampleInfo("Persistence CompleteHistoryTask called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceCompleteHistoryTaskScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceCompleteHistoryTaskScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceCompleteHistoryTaskScope, op, append(getCustomMetricTags(request), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) ConflictResolveWorkflowExecution(ctx context.Context, request *persistence.ConflictResolveWorkflowExecutionRequest) (cp1 *persistence.ConflictResolveWorkflowExecutionResponse, err error) {
	op := func() error {
		cp1, err = c.wrapped.ConflictResolveWorkflowExecution(ctx, request)
		c.emptyMetric("ExecutionManager.ConflictResolveWorkflowExecution", request, cp1, err)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(request); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(request)...)
		c.logger.SampleInfo("Persistence ConflictResolveWorkflowExecution called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceConflictResolveWorkflowExecutionScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceConflictResolveWorkflowExecutionScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceConflictResolveWorkflowExecutionScope, op, append(getCustomMetricTags(request), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) CreateFailoverMarkerTasks(ctx context.Context, request *persistence.CreateFailoverMarkersRequest) (err error) {
	op := func() error {
		err = c.wrapped.CreateFailoverMarkerTasks(ctx, request)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(request); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(request)...)
		c.logger.SampleInfo("Persistence CreateFailoverMarkerTasks called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceCreateFailoverMarkerTasksScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceCreateFailoverMarkerTasksScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceCreateFailoverMarkerTasksScope, op, append(getCustomMetricTags(request), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) CreateWorkflowExecution(ctx context.Context, request *persistence.CreateWorkflowExecutionRequest) (cp1 *persistence.CreateWorkflowExecutionResponse, err error) {
	op := func() error {
		cp1, err = c.wrapped.CreateWorkflowExecution(ctx, request)
		c.emptyMetric("ExecutionManager.CreateWorkflowExecution", request, cp1, err)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(request); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(request)...)
		c.logger.SampleInfo("Persistence CreateWorkflowExecution called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceCreateWorkflowExecutionScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceCreateWorkflowExecutionScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceCreateWorkflowExecutionScope, op, append(getCustomMetricTags(request), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) DeleteActiveClusterSelectionPolicy(ctx context.Context, domainID string, workflowID string, runID string) (err error) {
	op := func() error {
		err = c.wrapped.DeleteActiveClusterSelectionPolicy(ctx, domainID, workflowID, runID)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(domainID); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(domainID)...)
		c.logger.SampleInfo("Persistence DeleteActiveClusterSelectionPolicy called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceDeleteActiveClusterSelectionPolicyScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceDeleteActiveClusterSelectionPolicyScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceDeleteActiveClusterSelectionPolicyScope, op, append(getCustomMetricTags(domainID), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) DeleteCurrentWorkflowExecution(ctx context.Context, request *persistence.DeleteCurrentWorkflowExecutionRequest) (err error) {
	op := func() error {
		err = c.wrapped.DeleteCurrentWorkflowExecution(ctx, request)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(request); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(request)...)
		c.logger.SampleInfo("Persistence DeleteCurrentWorkflowExecution called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceDeleteCurrentWorkflowExecutionScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceDeleteCurrentWorkflowExecutionScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceDeleteCurrentWorkflowExecutionScope, op, append(getCustomMetricTags(request), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) DeleteReplicationTaskFromDLQ(ctx context.Context, request *persistence.DeleteReplicationTaskFromDLQRequest) (err error) {
	op := func() error {
		err = c.wrapped.DeleteReplicationTaskFromDLQ(ctx, request)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(request); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(request)...)
		c.logger.SampleInfo("Persistence DeleteReplicationTaskFromDLQ called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceDeleteReplicationTaskFromDLQScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceDeleteReplicationTaskFromDLQScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceDeleteReplicationTaskFromDLQScope, op, append(getCustomMetricTags(request), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) DeleteWorkflowExecution(ctx context.Context, request *persistence.DeleteWorkflowExecutionRequest) (err error) {
	op := func() error {
		err = c.wrapped.DeleteWorkflowExecution(ctx, request)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(request); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(request)...)
		c.logger.SampleInfo("Persistence DeleteWorkflowExecution called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceDeleteWorkflowExecutionScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceDeleteWorkflowExecutionScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceDeleteWorkflowExecutionScope, op, append(getCustomMetricTags(request), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) GetActiveClusterSelectionPolicy(ctx context.Context, domainID string, wfID string, rID string) (ap1 *types.ActiveClusterSelectionPolicy, err error) {
	op := func() error {
		ap1, err = c.wrapped.GetActiveClusterSelectionPolicy(ctx, domainID, wfID, rID)
		c.emptyMetric("ExecutionManager.GetActiveClusterSelectionPolicy", domainID, ap1, err)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(domainID); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(domainID)...)
		c.logger.SampleInfo("Persistence GetActiveClusterSelectionPolicy called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceGetActiveClusterSelectionPolicyScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceGetActiveClusterSelectionPolicyScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceGetActiveClusterSelectionPolicyScope, op, append(getCustomMetricTags(domainID), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) GetCurrentExecution(ctx context.Context, request *persistence.GetCurrentExecutionRequest) (gp1 *persistence.GetCurrentExecutionResponse, err error) {
	op := func() error {
		gp1, err = c.wrapped.GetCurrentExecution(ctx, request)
		c.emptyMetric("ExecutionManager.GetCurrentExecution", request, gp1, err)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(request); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(request)...)
		c.logger.SampleInfo("Persistence GetCurrentExecution called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceGetCurrentExecutionScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceGetCurrentExecutionScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceGetCurrentExecutionScope, op, append(getCustomMetricTags(request), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) GetHistoryTasks(ctx context.Context, request *persistence.GetHistoryTasksRequest) (gp1 *persistence.GetHistoryTasksResponse, err error) {
	op := func() error {
		gp1, err = c.wrapped.GetHistoryTasks(ctx, request)
		c.emptyMetric("ExecutionManager.GetHistoryTasks", request, gp1, err)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(request); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(request)...)
		c.logger.SampleInfo("Persistence GetHistoryTasks called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceGetHistoryTasksScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceGetHistoryTasksScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceGetHistoryTasksScope, op, append(getCustomMetricTags(request), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) GetName() (s1 string) {
	return c.wrapped.GetName()
}

func (c *meteredExecutionManager) GetReplicationDLQSize(ctx context.Context, request *persistence.GetReplicationDLQSizeRequest) (gp1 *persistence.GetReplicationDLQSizeResponse, err error) {
	op := func() error {
		gp1, err = c.wrapped.GetReplicationDLQSize(ctx, request)
		c.emptyMetric("ExecutionManager.GetReplicationDLQSize", request, gp1, err)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(request); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(request)...)
		c.logger.SampleInfo("Persistence GetReplicationDLQSize called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceGetReplicationDLQSizeScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceGetReplicationDLQSizeScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceGetReplicationDLQSizeScope, op, append(getCustomMetricTags(request), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) GetReplicationTasksFromDLQ(ctx context.Context, request *persistence.GetReplicationTasksFromDLQRequest) (gp1 *persistence.GetHistoryTasksResponse, err error) {
	op := func() error {
		gp1, err = c.wrapped.GetReplicationTasksFromDLQ(ctx, request)
		c.emptyMetric("ExecutionManager.GetReplicationTasksFromDLQ", request, gp1, err)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(request); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(request)...)
		c.logger.SampleInfo("Persistence GetReplicationTasksFromDLQ called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceGetReplicationTasksFromDLQScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceGetReplicationTasksFromDLQScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceGetReplicationTasksFromDLQScope, op, append(getCustomMetricTags(request), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) GetShardID() (i1 int) {
	return c.wrapped.GetShardID()
}

func (c *meteredExecutionManager) GetWorkflowExecution(ctx context.Context, request *persistence.GetWorkflowExecutionRequest) (gp1 *persistence.GetWorkflowExecutionResponse, err error) {
	op := func() error {
		gp1, err = c.wrapped.GetWorkflowExecution(ctx, request)
		c.emptyMetric("ExecutionManager.GetWorkflowExecution", request, gp1, err)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(request); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(request)...)
		c.logger.SampleInfo("Persistence GetWorkflowExecution called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceGetWorkflowExecutionScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceGetWorkflowExecutionScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceGetWorkflowExecutionScope, op, append(getCustomMetricTags(request), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) IsWorkflowExecutionExists(ctx context.Context, request *persistence.IsWorkflowExecutionExistsRequest) (ip1 *persistence.IsWorkflowExecutionExistsResponse, err error) {
	op := func() error {
		ip1, err = c.wrapped.IsWorkflowExecutionExists(ctx, request)
		c.emptyMetric("ExecutionManager.IsWorkflowExecutionExists", request, ip1, err)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(request); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(request)...)
		c.logger.SampleInfo("Persistence IsWorkflowExecutionExists called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceIsWorkflowExecutionExistsScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceIsWorkflowExecutionExistsScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceIsWorkflowExecutionExistsScope, op, append(getCustomMetricTags(request), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) ListConcreteExecutions(ctx context.Context, request *persistence.ListConcreteExecutionsRequest) (lp1 *persistence.ListConcreteExecutionsResponse, err error) {
	op := func() error {
		lp1, err = c.wrapped.ListConcreteExecutions(ctx, request)
		c.emptyMetric("ExecutionManager.ListConcreteExecutions", request, lp1, err)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(request); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(request)...)
		c.logger.SampleInfo("Persistence ListConcreteExecutions called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceListConcreteExecutionsScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceListConcreteExecutionsScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceListConcreteExecutionsScope, op, append(getCustomMetricTags(request), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) ListCurrentExecutions(ctx context.Context, request *persistence.ListCurrentExecutionsRequest) (lp1 *persistence.ListCurrentExecutionsResponse, err error) {
	op := func() error {
		lp1, err = c.wrapped.ListCurrentExecutions(ctx, request)
		c.emptyMetric("ExecutionManager.ListCurrentExecutions", request, lp1, err)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(request); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(request)...)
		c.logger.SampleInfo("Persistence ListCurrentExecutions called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceListCurrentExecutionsScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceListCurrentExecutionsScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceListCurrentExecutionsScope, op, append(getCustomMetricTags(request), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) PutReplicationTaskToDLQ(ctx context.Context, request *persistence.PutReplicationTaskToDLQRequest) (err error) {
	op := func() error {
		err = c.wrapped.PutReplicationTaskToDLQ(ctx, request)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(request); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(request)...)
		c.logger.SampleInfo("Persistence PutReplicationTaskToDLQ called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistencePutReplicationTaskToDLQScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistencePutReplicationTaskToDLQScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistencePutReplicationTaskToDLQScope, op, append(getCustomMetricTags(request), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) RangeCompleteHistoryTask(ctx context.Context, request *persistence.RangeCompleteHistoryTaskRequest) (rp1 *persistence.RangeCompleteHistoryTaskResponse, err error) {
	op := func() error {
		rp1, err = c.wrapped.RangeCompleteHistoryTask(ctx, request)
		c.emptyMetric("ExecutionManager.RangeCompleteHistoryTask", request, rp1, err)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(request); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(request)...)
		c.logger.SampleInfo("Persistence RangeCompleteHistoryTask called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceRangeCompleteHistoryTaskScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceRangeCompleteHistoryTaskScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceRangeCompleteHistoryTaskScope, op, append(getCustomMetricTags(request), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) RangeDeleteReplicationTaskFromDLQ(ctx context.Context, request *persistence.RangeDeleteReplicationTaskFromDLQRequest) (rp1 *persistence.RangeDeleteReplicationTaskFromDLQResponse, err error) {
	op := func() error {
		rp1, err = c.wrapped.RangeDeleteReplicationTaskFromDLQ(ctx, request)
		c.emptyMetric("ExecutionManager.RangeDeleteReplicationTaskFromDLQ", request, rp1, err)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(request); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(request)...)
		c.logger.SampleInfo("Persistence RangeDeleteReplicationTaskFromDLQ called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceRangeDeleteReplicationTaskFromDLQScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceRangeDeleteReplicationTaskFromDLQScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceRangeDeleteReplicationTaskFromDLQScope, op, append(getCustomMetricTags(request), metrics.IsRetryTag(retryCount > 0))...)

	return
}

func (c *meteredExecutionManager) UpdateWorkflowExecution(ctx context.Context, request *persistence.UpdateWorkflowExecutionRequest) (up1 *persistence.UpdateWorkflowExecutionResponse, err error) {
	op := func() error {
		up1, err = c.wrapped.UpdateWorkflowExecution(ctx, request)
		c.emptyMetric("ExecutionManager.UpdateWorkflowExecution", request, up1, err)
		return err
	}

	retryCount := getRetryCountFromContext(ctx)
	if domainName, hasDomainName := getDomainNameFromRequest(request); hasDomainName {
		logTags := append([]tag.Tag{tag.WorkflowDomainName(domainName)}, getCustomLogTags(request)...)
		c.logger.SampleInfo("Persistence UpdateWorkflowExecution called", c.sampleLoggingRate(), logTags...)
		if c.enableShardIDMetrics() {
			err = c.callWithDomainAndShardScope(metrics.PersistenceUpdateWorkflowExecutionScope, op, metrics.DomainTag(domainName),
				metrics.ShardIDTag(c.GetShardID()), metrics.IsRetryTag(retryCount > 0))
		} else {
			err = c.call(metrics.PersistenceUpdateWorkflowExecutionScope, op, metrics.DomainTag(domainName), metrics.IsRetryTag(retryCount > 0))
		}
		return
	}

	err = c.callWithoutDomainTag(metrics.PersistenceUpdateWorkflowExecutionScope, op, append(getCustomMetricTags(request), metrics.IsRetryTag(retryCount > 0))...)

	return
}
