|
22 | 22 | import com.uber.cadence.PollForDecisionTaskResponse;
|
23 | 23 | import com.uber.cadence.ServiceBusyError;
|
24 | 24 | import com.uber.cadence.TaskList;
|
| 25 | +import com.uber.cadence.internal.metrics.MetricsTag; |
25 | 26 | import com.uber.cadence.internal.metrics.MetricsType;
|
26 | 27 | import com.uber.cadence.serviceclient.IWorkflowService;
|
27 | 28 | import com.uber.m3.tally.Scope;
|
28 | 29 | import com.uber.m3.tally.Stopwatch;
|
29 | 30 | import com.uber.m3.util.Duration;
|
| 31 | +import com.uber.m3.util.ImmutableMap; |
30 | 32 | import java.util.Objects;
|
31 | 33 | import org.apache.thrift.TException;
|
32 | 34 | import org.slf4j.Logger;
|
33 | 35 | import org.slf4j.LoggerFactory;
|
34 | 36 |
|
35 | 37 | final class WorkflowPollTask implements Poller.PollTask<PollForDecisionTaskResponse> {
|
36 | 38 |
|
| 39 | + private static final Logger log = LoggerFactory.getLogger(WorkflowWorker.class); |
37 | 40 | private final Scope metricScope;
|
38 | 41 | private final IWorkflowService service;
|
39 | 42 | private final String domain;
|
40 | 43 | private final String taskList;
|
41 | 44 | private final String identity;
|
42 |
| - private static final Logger log = LoggerFactory.getLogger(WorkflowWorker.class); |
43 | 45 |
|
44 | 46 | WorkflowPollTask(
|
45 | 47 | IWorkflowService service,
|
@@ -92,17 +94,20 @@ public PollForDecisionTaskResponse poll() throws TException {
|
92 | 94 | + ", previousStartedEventId="
|
93 | 95 | + result.getPreviousStartedEventId()
|
94 | 96 | + (result.getQuery() != null
|
95 |
| - ? ", queryType=" + result.getQuery().getQueryType() |
96 |
| - : "")); |
| 97 | + ? ", queryType=" + result.getQuery().getQueryType() |
| 98 | + : "")); |
97 | 99 | }
|
98 | 100 |
|
99 | 101 | if (result == null || result.getTaskToken() == null) {
|
100 | 102 | metricScope.counter(MetricsType.DECISION_POLL_NO_TASK_COUNTER).inc(1);
|
101 | 103 | return null;
|
102 | 104 | }
|
103 | 105 |
|
104 |
| - metricScope.counter(MetricsType.DECISION_POLL_SUCCEED_COUNTER).inc(1); |
105 |
| - metricScope |
| 106 | + Scope metricsScope = |
| 107 | + metricScope |
| 108 | + .tagged(ImmutableMap.of(MetricsTag.WORKFLOW_TYPE, result.getWorkflowType().getName())); |
| 109 | + metricsScope.counter(MetricsType.DECISION_POLL_SUCCEED_COUNTER).inc(1); |
| 110 | + metricsScope |
106 | 111 | .timer(MetricsType.DECISION_SCHEDULED_TO_START_LATENCY)
|
107 | 112 | .record(Duration.ofNanos(result.getStartedTimestamp() - result.getScheduledTimestamp()));
|
108 | 113 | sw.stop();
|
|
0 commit comments