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);
}
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);
}
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();
}
Aggregations