use of com.uber.jaeger.crossdock.api.JoinTraceRequest in project jaeger-client-java by jaegertracing.
the class TraceBehavior method callDownstreamHttp.
private TraceResponse callDownstreamHttp(Downstream downstream) throws IOException {
String downstreamUrl = String.format("http://%s:%s/join_trace", downstream.getHost(), downstream.getPort());
log.info("Calling downstream http {} at {}", downstream.getServiceName(), downstreamUrl);
Response resp = JerseyServer.client.target(downstreamUrl).request(MediaType.APPLICATION_JSON).post(Entity.json(new JoinTraceRequest(downstream.getServerRole(), downstream.getDownstream())));
String respStr = resp.readEntity(String.class);
TraceResponse response = mapper.readValue(respStr, TraceResponse.class);
log.info("Received response {}", response);
return response;
}
use of com.uber.jaeger.crossdock.api.JoinTraceRequest 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());
}
}
use of com.uber.jaeger.crossdock.api.JoinTraceRequest in project jaeger-client-java by jaegertracing.
the class TraceBehaviorResourceTest method testJoinTraceHttp.
@Test
public void testJoinTraceHttp() throws Exception {
Span span = (Span) server.getTracer().buildSpan("root").start();
TracingUtils.getTraceContext().push(span);
String expectedBaggage = "baggage-example";
span.setBaggageItem(Constants.BAGGAGE_KEY, expectedBaggage);
if (expectedSampled) {
Tags.SAMPLING_PRIORITY.set(span, 1);
}
Downstream bottomDownstream = new Downstream(SERVICE_NAME, "127.0.0.1", port, Constants.TRANSPORT_HTTP, "server", null);
Downstream topDownstream = new Downstream(SERVICE_NAME, "127.0.0.1", port, Constants.TRANSPORT_HTTP, "server", bottomDownstream);
JoinTraceRequest joinTraceRequest = new JoinTraceRequest("server-role", topDownstream);
Response resp = JerseyServer.client.target(String.format("http://%s/join_trace", hostPort)).request(MediaType.APPLICATION_JSON).post(Entity.json(joinTraceRequest));
TraceResponse traceResponse = resp.readEntity(TraceResponse.class);
assertNotNull(traceResponse.getDownstream());
validateTraceResponse(traceResponse, String.format("%x", span.context().getTraceId()), expectedBaggage, 2);
}
Aggregations