Search in sources :

Example 1 with JoinTraceRequest

use of io.jaegertracing.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(io.jaegertracing.crossdock.api.TraceResponse) Response(javax.ws.rs.core.Response) JoinTraceRequest(io.jaegertracing.crossdock.api.JoinTraceRequest) TraceResponse(io.jaegertracing.crossdock.api.TraceResponse)

Example 2 with JoinTraceRequest

use of io.jaegertracing.crossdock.api.JoinTraceRequest in project jaeger-client-java by jaegertracing.

the class TraceBehaviorResourceTest method testJoinTraceHttp.

@Test
public void testJoinTraceHttp() throws Exception {
    Span root = server.getTracer().buildSpan("root").start();
    String expectedBaggage = "baggage-example";
    root.setBaggageItem(Constants.BAGGAGE_KEY, expectedBaggage);
    if (expectedSampled) {
        Tags.SAMPLING_PRIORITY.set(root, 1);
    }
    try (Scope scope = server.getTracer().activateSpan(root)) {
        Downstream bottomDownstream = new Downstream(SERVICE_NAME, "127.0.0.1", String.valueOf(port), Constants.TRANSPORT_HTTP, "server", null);
        Downstream topDownstream = new Downstream(SERVICE_NAME, "127.0.0.1", String.valueOf(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, ((JaegerSpanContext) root.context()).getTraceId(), expectedBaggage, 2);
    }
}
Also used : TraceResponse(io.jaegertracing.crossdock.api.TraceResponse) Response(javax.ws.rs.core.Response) Scope(io.opentracing.Scope) JoinTraceRequest(io.jaegertracing.crossdock.api.JoinTraceRequest) ObservedSpan(io.jaegertracing.crossdock.api.ObservedSpan) Span(io.opentracing.Span) Downstream(io.jaegertracing.crossdock.api.Downstream) TraceResponse(io.jaegertracing.crossdock.api.TraceResponse) Test(org.junit.Test)

Aggregations

JoinTraceRequest (io.jaegertracing.crossdock.api.JoinTraceRequest)2 TraceResponse (io.jaegertracing.crossdock.api.TraceResponse)2 Response (javax.ws.rs.core.Response)2 Downstream (io.jaegertracing.crossdock.api.Downstream)1 ObservedSpan (io.jaegertracing.crossdock.api.ObservedSpan)1 Scope (io.opentracing.Scope)1 Span (io.opentracing.Span)1 Test (org.junit.Test)1