|
96 | 96 | import com.uber.cadence.internal.Version;
|
97 | 97 | import com.uber.cadence.internal.common.CheckedExceptionWrapper;
|
98 | 98 | import com.uber.cadence.internal.common.InternalUtils;
|
| 99 | +import com.uber.cadence.internal.metrics.MetricsTag; |
99 | 100 | import com.uber.cadence.internal.metrics.MetricsType;
|
100 | 101 | import com.uber.cadence.internal.metrics.ServiceMethod;
|
101 | 102 | import com.uber.m3.tally.Scope;
|
|
109 | 110 | import com.uber.tchannel.messages.ThriftRequest;
|
110 | 111 | import com.uber.tchannel.messages.ThriftResponse;
|
111 | 112 | import com.uber.tchannel.messages.generated.Meta;
|
| 113 | +import org.apache.thrift.TException; |
| 114 | +import org.apache.thrift.async.AsyncMethodCallback; |
| 115 | +import org.apache.thrift.transport.TTransportException; |
| 116 | +import org.slf4j.Logger; |
| 117 | +import org.slf4j.LoggerFactory; |
| 118 | + |
112 | 119 | import java.net.InetAddress;
|
113 | 120 | import java.net.InetSocketAddress;
|
114 | 121 | import java.net.UnknownHostException;
|
|
119 | 126 | import java.util.UUID;
|
120 | 127 | import java.util.concurrent.CompletableFuture;
|
121 | 128 | import java.util.concurrent.ExecutionException;
|
122 |
| -import org.apache.thrift.TException; |
123 |
| -import org.apache.thrift.async.AsyncMethodCallback; |
124 |
| -import org.apache.thrift.transport.TTransportException; |
125 |
| -import org.slf4j.Logger; |
126 |
| -import org.slf4j.LoggerFactory; |
| 129 | + |
| 130 | +import static com.uber.cadence.internal.metrics.MetricsTagValue.REQUEST_TYPE_LONG_POLL; |
| 131 | +import static com.uber.cadence.internal.metrics.MetricsTagValue.REQUEST_TYPE_NORMAL; |
127 | 132 |
|
128 | 133 | public class WorkflowServiceTChannel implements IWorkflowService {
|
129 | 134 | private static final Logger log = LoggerFactory.getLogger(WorkflowServiceTChannel.class);
|
@@ -355,7 +360,14 @@ interface RemoteCall<T> {
|
355 | 360 | }
|
356 | 361 |
|
357 | 362 | private <T> T measureRemoteCall(String scopeName, RemoteCall<T> call) throws TException {
|
| 363 | + return measureRemoteCallWithTags(scopeName, call, null); |
| 364 | + } |
| 365 | + |
| 366 | + private <T> T measureRemoteCallWithTags(String scopeName, RemoteCall<T> call, Map<String, String> tags) throws TException { |
358 | 367 | Scope scope = options.getMetricsScope().subScope(scopeName);
|
| 368 | + if (tags != null) { |
| 369 | + scope = scope.tagged(tags); |
| 370 | + } |
359 | 371 | scope.counter(MetricsType.CADENCE_REQUEST).inc(1);
|
360 | 372 | Stopwatch sw = scope.timer(MetricsType.CADENCE_LATENCY).start();
|
361 | 373 | try {
|
@@ -665,17 +677,21 @@ private StartWorkflowExecutionResponse startWorkflowExecution(
|
665 | 677 | @Override
|
666 | 678 | public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistoryWithTimeout(
|
667 | 679 | GetWorkflowExecutionHistoryRequest request, Long timeoutInMillis) throws TException {
|
668 |
| - return measureRemoteCall( |
669 |
| - ServiceMethod.GET_WORKFLOW_EXECUTION_HISTORY, |
670 |
| - () -> getWorkflowExecutionHistory(request, timeoutInMillis)); |
| 680 | + Map<String, String> tags = ImmutableMap.of(MetricsTag.REQUEST_TYPE, request.isWaitForNewEvent() ? REQUEST_TYPE_LONG_POLL : REQUEST_TYPE_NORMAL); |
| 681 | + return measureRemoteCallWithTags( |
| 682 | + ServiceMethod.GET_WORKFLOW_EXECUTION_HISTORY, |
| 683 | + () -> getWorkflowExecutionHistory(request, timeoutInMillis), |
| 684 | + tags); |
671 | 685 | }
|
672 | 686 |
|
673 | 687 | @Override
|
674 | 688 | public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistory(
|
675 | 689 | GetWorkflowExecutionHistoryRequest request) throws TException {
|
676 |
| - return measureRemoteCall( |
677 |
| - ServiceMethod.GET_WORKFLOW_EXECUTION_HISTORY, |
678 |
| - () -> getWorkflowExecutionHistory(request, null)); |
| 690 | + Map<String, String> tags = ImmutableMap.of(MetricsTag.REQUEST_TYPE, request.isWaitForNewEvent() ? REQUEST_TYPE_LONG_POLL : REQUEST_TYPE_NORMAL); |
| 691 | + return measureRemoteCallWithTags( |
| 692 | + ServiceMethod.GET_WORKFLOW_EXECUTION_HISTORY, |
| 693 | + () -> getWorkflowExecutionHistory(request, null), |
| 694 | + tags); |
679 | 695 | }
|
680 | 696 |
|
681 | 697 | private GetWorkflowExecutionHistoryResponse getWorkflowExecutionHistory(
|
|
0 commit comments