Skip to content

Commit

Permalink
Consistent query pershard metric (uber#5143)
Browse files Browse the repository at this point in the history
* added and update consistent query per shard metric

* testing pershard metric

* move sample logger into persistence metric client for cleaness

* fix test

* fix lint

* fix test again

* fix lint

* sample logging with workflowid tag

* added domain tag to logger

* metric completed

* addressing comments

* fix lint

* Revert "fix lint"

This reverts commit 1e96944.

* fix lint second attempt

---------

Co-authored-by: Allen Chen <allenchen2244@uber.com>
  • Loading branch information
ketsiambaku and allenchen2244 committed Mar 13, 2023
1 parent 61c64c3 commit 9581488
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions common/metrics/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2226,6 +2226,7 @@ const (
DirectQueryDispatchClearStickinessSuccessCount
DirectQueryDispatchTimeoutBeforeNonStickyCount
DecisionTaskQueryLatency
ConsistentQueryPerShard
ConsistentQueryTimeoutCount
QueryBeforeFirstDecisionCount
QueryBufferExceededCount
Expand Down Expand Up @@ -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},
Expand Down
10 changes: 8 additions & 2 deletions service/history/historyEngine.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"encoding/json"
"errors"
"fmt"
"strconv"
"time"

"github.com/pborman/uuid"
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 9581488

Please sign in to comment.