Search in sources :

Example 1 with StartTraceRequest

use of io.jaegertracing.crossdock.api.StartTraceRequest 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);
    }
}
Also used : StartTraceRequest(io.jaegertracing.crossdock.api.StartTraceRequest) TraceResponse(io.jaegertracing.crossdock.api.TraceResponse) Response(javax.ws.rs.core.Response) Scope(io.opentracing.Scope) ObservedSpan(io.jaegertracing.crossdock.api.ObservedSpan) Span(io.opentracing.Span) Downstream(io.jaegertracing.crossdock.api.Downstream) JaegerSpanContext(io.jaegertracing.internal.JaegerSpanContext) TraceResponse(io.jaegertracing.crossdock.api.TraceResponse) Test(org.junit.Test)

Aggregations

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