use of com.uber.jaeger.crossdock.api.TraceResponse 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;
}
use of com.uber.jaeger.crossdock.api.TraceResponse in project jaeger-client-java by jaegertracing.
the class TraceBehavior method prepareResponse.
public TraceResponse prepareResponse(Downstream downstream) throws Exception {
TraceResponse response = new TraceResponse(observeSpan());
if (downstream != null) {
TraceResponse downstreamResponse = callDownstream(downstream);
response.setDownstream(downstreamResponse);
}
return response;
}
use of com.uber.jaeger.crossdock.api.TraceResponse in project jaeger-client-java by jaegertracing.
the class TraceBehaviorResource method startTrace.
@POST
@Path("start_trace")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public TraceResponse startTrace(StartTraceRequest startRequest) throws Exception {
log.info("http:start_trace request: {}", mapper.writeValueAsString(startRequest));
// TODO should be starting new root span
Span span = (Span) TracingUtils.getTraceContext().getCurrentSpan();
String baggage = startRequest.getBaggage();
span.setBaggageItem(Constants.BAGGAGE_KEY, baggage);
if (startRequest.isSampled()) {
Tags.SAMPLING_PRIORITY.set(span, 1);
}
TraceResponse response = behavior.prepareResponse(startRequest.getDownstream());
log.info("http:start_trace response: {}", mapper.writeValueAsString(response));
return response;
}
use of com.uber.jaeger.crossdock.api.TraceResponse in project jaeger-client-java by jaegertracing.
the class JoinTraceThriftHandler method handleImpl.
@Override
public ThriftResponse<TracedService.joinTrace_result> handleImpl(ThriftRequest<TracedService.joinTrace_args> thriftRequest) {
JoinTraceRequest request = thriftRequest.getBody(TracedService.joinTrace_args.class).getRequest();
log.info("thrift:join_trace request: {}", request);
TraceResponse response;
try {
response = behavior.prepareResponse(Downstream.fromThrift(request.getDownstream()));
} catch (Exception e) {
log.error("Failed to call downstream", e);
response = new TraceResponse(e.getMessage());
}
log.info("thrift:join_trace response: {}", response);
return new ThriftResponse.Builder<TracedService.joinTrace_result>(thriftRequest).setBody(new TracedService.joinTrace_result(TraceResponse.toThrift(response))).build();
}
use of com.uber.jaeger.crossdock.api.TraceResponse 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);
}
Aggregations