use of com.uber.tchannel.messages.ThriftResponse in project jaeger-client-java by jaegertracing.
the class TraceBehavior method callDownstreamTChannel.
public TraceResponse callDownstreamTChannel(Downstream downstream) throws Exception {
com.uber.jaeger.crossdock.thrift.JoinTraceRequest joinTraceRequest = new com.uber.jaeger.crossdock.thrift.JoinTraceRequest(downstream.getServerRole());
joinTraceRequest.setDownstream(Downstream.toThrift(downstream.getDownstream()));
SubChannel subChannel = TChannelServer.server.makeSubChannel(downstream.getServiceName());
log.info("Calling downstream tchannel {}", joinTraceRequest);
ThriftRequest<TracedService.joinTrace_args> thriftRequest = new ThriftRequest.Builder<TracedService.joinTrace_args>(downstream.getServiceName(), "TracedService::joinTrace").setTimeout(2000).setBody(new TracedService.joinTrace_args(joinTraceRequest)).build();
TFuture<ThriftResponse<TracedService.joinTrace_result>> future = subChannel.send(thriftRequest, host(downstream), port(downstream));
try (ThriftResponse<TracedService.joinTrace_result> thriftResponse = future.get()) {
log.info("Received tchannel response {}", thriftResponse);
if (thriftResponse.isError()) {
throw new Exception(thriftResponse.getError().getMessage());
}
return TraceResponse.fromThrift(thriftResponse.getBody(TracedService.joinTrace_result.class).getSuccess());
}
}
Aggregations