Search in sources :

Example 1 with Downstream

use of com.uber.jaeger.crossdock.api.Downstream in project jaeger-client-java by jaegertracing.

the class TraceBehaviorResourceTest method testStartTraceHttp.

@Test
public void testStartTraceHttp() throws Exception {
    Span span = (Span) server.getTracer().buildSpan("root").start();
    TracingUtils.getTraceContext().push(span);
    String expectedTraceId = String.format("%x", span.context().getTraceId());
    String expectedBaggage = "baggage-example";
    Downstream downstream = new Downstream(SERVICE_NAME, "127.0.0.1", port, Constants.TRANSPORT_HTTP, "server", null);
    StartTraceRequest startTraceRequest = new StartTraceRequest("server-role", expectedSampled, expectedBaggage, downstream);
    Response resp = JerseyServer.client.target(String.format("http://%s/start_trace", hostPort)).request(MediaType.APPLICATION_JSON).post(Entity.json(startTraceRequest));
    TraceResponse traceResponse = resp.readEntity(TraceResponse.class);
    assertNotNull(traceResponse.getDownstream());
    validateTraceResponse(traceResponse, expectedTraceId, expectedBaggage, 1);
}
Also used : StartTraceRequest(com.uber.jaeger.crossdock.api.StartTraceRequest) TraceResponse(com.uber.jaeger.crossdock.api.TraceResponse) Response(javax.ws.rs.core.Response) 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)

Example 2 with Downstream

use of com.uber.jaeger.crossdock.api.Downstream 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)

Example 3 with Downstream

use of com.uber.jaeger.crossdock.api.Downstream in project jaeger-client-java by jaegertracing.

the class TraceBehaviorResourceTest method testJoinTraceTChannel.

@Test
public void testJoinTraceTChannel() throws Exception {
    Builder tchannelBuilder = new Builder("foo");
    tchannelBuilder.setServerPort(0);
    tchannelBuilder.setServerHost(InetAddress.getLoopbackAddress());
    TChannelServer tchannel = new TChannelServer(tchannelBuilder, behavior, server.getTracer());
    tchannel.start();
    Span span = (Span) server.getTracer().buildSpan("root").startManual();
    TracingUtils.getTraceContext().push(span);
    String expectedBaggage = "baggage-example";
    span.setBaggageItem(Constants.BAGGAGE_KEY, expectedBaggage);
    if (expectedSampled) {
        Tags.SAMPLING_PRIORITY.set(span, 1);
    }
    TraceResponse response = behavior.callDownstreamTChannel(new Downstream(SERVICE_NAME, tchannel.getChannel().getListeningHost(), String.valueOf(tchannel.getChannel().getListeningPort()), Constants.TRANSPORT_TCHANNEL, "s2", new Downstream(SERVICE_NAME, tchannel.getChannel().getListeningHost(), String.valueOf(tchannel.getChannel().getListeningPort()), Constants.TRANSPORT_TCHANNEL, "s3", null)));
    assertNotNull(response);
    validateTraceResponse(response, String.format("%x", span.context().getTraceId()), expectedBaggage, 1);
    tchannel.shutdown();
}
Also used : Builder(com.uber.tchannel.api.TChannel.Builder) TChannelServer(com.uber.jaeger.crossdock.resources.behavior.tchannel.TChannelServer) 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

Span (com.uber.jaeger.Span)3 Downstream (com.uber.jaeger.crossdock.api.Downstream)3 ObservedSpan (com.uber.jaeger.crossdock.api.ObservedSpan)3 TraceResponse (com.uber.jaeger.crossdock.api.TraceResponse)3 Test (org.junit.Test)3 Response (javax.ws.rs.core.Response)2 JoinTraceRequest (com.uber.jaeger.crossdock.api.JoinTraceRequest)1 StartTraceRequest (com.uber.jaeger.crossdock.api.StartTraceRequest)1 TChannelServer (com.uber.jaeger.crossdock.resources.behavior.tchannel.TChannelServer)1 Builder (com.uber.tchannel.api.TChannel.Builder)1