Skip to content

Commit

Permalink
Replace sticky tasklist metrics scope with the same value (#601)
Browse files Browse the repository at this point in the history
* Replace sticky tasklist metrics scope with the same value
  • Loading branch information
yux0 authored May 17, 2021
1 parent c45a8ec commit 26d092d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/uber/cadence/worker/WorkerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public static WorkerFactory newInstance(
"attempted to %s while in %s state. Acceptable States: %s";
private static final Logger log = LoggerFactory.getLogger(WorkerFactory.class);
private static final String STICKY_TASK_LIST_PREFIX = "sticky";
private static final String STICKY_TASK_LIST_METRIC_TAG = "__" + STICKY_TASK_LIST_PREFIX + "__";
private static final String POLL_THREAD_NAME = "Sticky Task Poller";

/**
Expand Down Expand Up @@ -113,7 +114,7 @@ public WorkerFactory(WorkflowClient workflowClient, WorkerFactoryOptions factory
MetricsTag.DOMAIN,
workflowClient.getOptions().getDomain(),
MetricsTag.TASK_LIST,
getStickyTaskListName()));
STICKY_TASK_LIST_METRIC_TAG));

this.cache = new DeciderCache(this.factoryOptions.getCacheMaximumSize(), stickyScope);
dispatcher = new PollDecisionTaskDispatcher(workflowClient.getService());
Expand Down
9 changes: 5 additions & 4 deletions src/test/java/com/uber/cadence/worker/StickyWorkerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class StickyWorkerTest {

private static final boolean useDockerService =
Boolean.parseBoolean(System.getenv("USE_DOCKER_SERVICE"));
private static final String STICKY_TASK_LIST_METRIC_TAG = "__sticky__";

@Parameterized.Parameter public boolean useExternalService;

Expand Down Expand Up @@ -151,7 +152,7 @@ public void whenStickyIsEnabledThenTheWorkflowIsCachedSignals() throws Exception
Map<String, String> tags =
new ImmutableMap.Builder<String, String>(2)
.put(MetricsTag.DOMAIN, DOMAIN)
.put(MetricsTag.TASK_LIST, factory.getStickyTaskListName())
.put(MetricsTag.TASK_LIST, STICKY_TASK_LIST_METRIC_TAG)
.build();
Thread.sleep(600);
verify(reporter, atLeastOnce())
Expand Down Expand Up @@ -265,7 +266,7 @@ public void whenStickyIsEnabledThenTheWorkflowIsCachedActivities() throws Except
Map<String, String> tags =
new ImmutableMap.Builder<String, String>(2)
.put(MetricsTag.DOMAIN, DOMAIN)
.put(MetricsTag.TASK_LIST, factory.getStickyTaskListName())
.put(MetricsTag.TASK_LIST, STICKY_TASK_LIST_METRIC_TAG)
.build();
verify(reporter, atLeastOnce())
.reportCounter(eq(MetricsType.STICKY_CACHE_HIT), eq(tags), anyInt());
Expand Down Expand Up @@ -314,7 +315,7 @@ public void whenStickyIsEnabledThenTheWorkflowIsCachedChildWorkflows() throws Ex
Map<String, String> tags =
new ImmutableMap.Builder<String, String>(2)
.put(MetricsTag.DOMAIN, DOMAIN)
.put(MetricsTag.TASK_LIST, factory.getStickyTaskListName())
.put(MetricsTag.TASK_LIST, STICKY_TASK_LIST_METRIC_TAG)
.build();
verify(reporter, atLeastOnce())
.reportCounter(eq(MetricsType.STICKY_CACHE_HIT), eq(tags), anyInt());
Expand Down Expand Up @@ -370,7 +371,7 @@ public void whenStickyIsEnabledThenTheWorkflowIsCachedMutableSideEffect() throws
Map<String, String> tags =
new ImmutableMap.Builder<String, String>(2)
.put(MetricsTag.DOMAIN, DOMAIN)
.put(MetricsTag.TASK_LIST, factory.getStickyTaskListName())
.put(MetricsTag.TASK_LIST, STICKY_TASK_LIST_METRIC_TAG)
.build();
verify(reporter, atLeastOnce())
.reportCounter(eq(MetricsType.STICKY_CACHE_HIT), eq(tags), anyInt());
Expand Down

0 comments on commit 26d092d

Please sign in to comment.