Search in sources :

Example 1 with JoinTraceRequest

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;
}
Also used : TraceResponse(com.uber.jaeger.crossdock.api.TraceResponse) Response(javax.ws.rs.core.Response) ThriftResponse(com.uber.tchannel.messages.ThriftResponse) JoinTraceRequest(com.uber.jaeger.crossdock.api.JoinTraceRequest) TraceResponse(com.uber.jaeger.crossdock.api.TraceResponse)

Example 2 with JoinTraceRequest

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());
    }
}
Also used : ThriftRequest(com.uber.tchannel.messages.ThriftRequest) JoinTraceRequest(com.uber.jaeger.crossdock.api.JoinTraceRequest) SubChannel(com.uber.tchannel.api.SubChannel) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) TracedService(com.uber.jaeger.crossdock.thrift.TracedService) ThriftResponse(com.uber.tchannel.messages.ThriftResponse)

Example 3 with JoinTraceRequest

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);
}
Also used : TraceResponse(com.uber.jaeger.crossdock.api.TraceResponse) Response(javax.ws.rs.core.Response) JoinTraceRequest(com.uber.jaeger.crossdock.api.JoinTraceRequest) Span(com.uber.jaeger.Span) ObservedSpan(com.uber.jaeger.crossdock.api.ObservedSpan) Downstream(com.uber.jaeger.crossdock.api.Downstream) TraceResponse(com.uber.jaeger.crossdock.api.TraceResponse) Test(org.junit.Test)

Aggregations

JoinTraceRequest (com.uber.jaeger.crossdock.api.JoinTraceRequest)3 TraceResponse (com.uber.jaeger.crossdock.api.TraceResponse)2 ThriftResponse (com.uber.tchannel.messages.ThriftResponse)2 Response (javax.ws.rs.core.Response)2 Span (com.uber.jaeger.Span)1 Downstream (com.uber.jaeger.crossdock.api.Downstream)1 ObservedSpan (com.uber.jaeger.crossdock.api.ObservedSpan)1 TracedService (com.uber.jaeger.crossdock.thrift.TracedService)1 SubChannel (com.uber.tchannel.api.SubChannel)1 ThriftRequest (com.uber.tchannel.messages.ThriftRequest)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 Test (org.junit.Test)1