use of io.jaegertracing.crossdock.api.Downstream in project jaeger-client-java by jaegertracing.
the class TraceBehaviorResourceTest method testStartTraceHttp.
@Test
public void testStartTraceHttp() throws Exception {
Span root = server.getTracer().buildSpan("root").start();
String expectedTraceId = ((JaegerSpanContext) root.context()).getTraceId();
String expectedBaggage = "baggage-example";
try (Scope scope = server.getTracer().activateSpan(root)) {
Downstream downstream = new Downstream(SERVICE_NAME, "127.0.0.1", String.valueOf(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 io.jaegertracing.crossdock.api.Downstream 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);
}
}
Aggregations