diff --git a/common/metrics/defs.go b/common/metrics/defs.go index 7ed4d2791dd..99de5345ad5 100644 --- a/common/metrics/defs.go +++ b/common/metrics/defs.go @@ -2226,6 +2226,7 @@ const ( DirectQueryDispatchClearStickinessSuccessCount DirectQueryDispatchTimeoutBeforeNonStickyCount DecisionTaskQueryLatency + ConsistentQueryPerShard ConsistentQueryTimeoutCount QueryBeforeFirstDecisionCount QueryBufferExceededCount @@ -2818,6 +2819,7 @@ var MetricDefs = map[ServiceIdx]map[int]metricDefinition{ DirectQueryDispatchClearStickinessSuccessCount: {metricName: "direct_query_dispatch_clear_stickiness_success", metricType: Counter}, DirectQueryDispatchTimeoutBeforeNonStickyCount: {metricName: "direct_query_dispatch_timeout_before_non_sticky", metricType: Counter}, DecisionTaskQueryLatency: {metricName: "decision_task_query_latency", metricType: Timer}, + ConsistentQueryPerShard: {metricName: "consistent_query_per_shard", metricType: Counter}, ConsistentQueryTimeoutCount: {metricName: "consistent_query_timeout", metricType: Counter}, QueryBeforeFirstDecisionCount: {metricName: "query_before_first_decision", metricType: Counter}, QueryBufferExceededCount: {metricName: "query_buffer_exceeded", metricType: Counter}, diff --git a/service/history/historyEngine.go b/service/history/historyEngine.go index 8173e1a2ffd..ad011cb5d90 100644 --- a/service/history/historyEngine.go +++ b/service/history/historyEngine.go @@ -27,6 +27,7 @@ import ( "encoding/json" "errors" "fmt" + "strconv" "time" "github.com/pborman/uuid" @@ -1157,10 +1158,15 @@ func (e *historyEngineImpl) QueryWorkflow( ) (retResp *types.HistoryQueryWorkflowResponse, retErr error) { scope := e.metricsClient.Scope(metrics.HistoryQueryWorkflowScope).Tagged(metrics.DomainTag(request.GetRequest().GetDomain())) + shardMetricScope := e.metricsClient.Scope(metrics.HistoryQueryWorkflowScope).Tagged(metrics.ShardIDTag(strconv.Itoa(e.shard.GetShardID()))) consistentQueryEnabled := e.config.EnableConsistentQuery() && e.config.EnableConsistentQueryByDomain(request.GetRequest().GetDomain()) - if request.GetRequest().GetQueryConsistencyLevel() == types.QueryConsistencyLevelStrong && !consistentQueryEnabled { - return nil, workflow.ErrConsistentQueryNotEnabled + if request.GetRequest().GetQueryConsistencyLevel() == types.QueryConsistencyLevelStrong { + if !consistentQueryEnabled { + return nil, workflow.ErrConsistentQueryNotEnabled + } + scope.IncCounter(metrics.ConsistentQueryPerShard) + shardMetricScope.IncCounter(metrics.ConsistentQueryPerShard) } execution := *request.GetRequest().GetExecution()