Search in sources :

Example 31 with FRONTEND

use of zipkin2.TestObjects.FRONTEND in project java by wavefrontHQ.

the class ZipkinPortUnificationHandlerTest method testZipkinHandler.

@Test
public void testZipkinHandler() throws Exception {
    ZipkinPortUnificationHandler handler = new ZipkinPortUnificationHandler("9411", new NoopHealthCheckManager(), mockTraceHandler, mockTraceSpanLogsHandler, null, () -> false, () -> false, null, new SpanSampler(new RateSampler(1.0D), () -> null), "ProxyLevelAppTag", null);
    Endpoint localEndpoint1 = Endpoint.newBuilder().serviceName("frontend").ip("10.0.0.1").build();
    zipkin2.Span spanServer1 = zipkin2.Span.newBuilder().traceId("2822889fe47043bd").id("2822889fe47043bd").kind(zipkin2.Span.Kind.SERVER).name("getservice").timestamp(startTime * 1000).duration(1234 * 1000).localEndpoint(localEndpoint1).putTag("http.method", "GET").putTag("http.url", "none+h1c://localhost:8881/").putTag("http.status_code", "200").build();
    Endpoint localEndpoint2 = Endpoint.newBuilder().serviceName("backend").ip("10.0.0.1").build();
    zipkin2.Span spanServer2 = zipkin2.Span.newBuilder().traceId("2822889fe47043bd").id("d6ab73f8a3930ae8").parentId("2822889fe47043bd").kind(zipkin2.Span.Kind.SERVER).name("getbackendservice").timestamp(startTime * 1000).duration(2234 * 1000).localEndpoint(localEndpoint2).putTag("http.method", "GET").putTag("http.url", "none+h2c://localhost:9000/api").putTag("http.status_code", "200").putTag("component", "jersey-server").putTag("application", "SpanLevelAppTag").addAnnotation(startTime * 1000, "start processing").build();
    zipkin2.Span spanServer3 = zipkin2.Span.newBuilder().traceId("2822889fe47043bd").id("d6ab73f8a3930ae8").kind(zipkin2.Span.Kind.CLIENT).name("getbackendservice2").timestamp(startTime * 1000).duration(2234 * 1000).localEndpoint(localEndpoint2).putTag("http.method", "GET").putTag("http.url", "none+h2c://localhost:9000/api").putTag("http.status_code", "200").putTag("component", "jersey-server").putTag("application", "SpanLevelAppTag").putTag("emptry.tag", "").addAnnotation(startTime * 1000, "start processing").build();
    List<zipkin2.Span> zipkinSpanList = ImmutableList.of(spanServer1, spanServer2, spanServer3);
    // Validate all codecs i.e. JSON_V1, JSON_V2, THRIFT and PROTO3.
    for (SpanBytesEncoder encoder : SpanBytesEncoder.values()) {
        ByteBuf content = Unpooled.copiedBuffer(encoder.encodeList(zipkinSpanList));
        // take care of mocks.
        doMockLifecycle(mockTraceHandler, mockTraceSpanLogsHandler);
        ChannelHandlerContext mockCtx = createNiceMock(ChannelHandlerContext.class);
        doMockLifecycle(mockCtx);
        FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "http://localhost:9411/api/v1/spans", content, true);
        handler.handleHttpMessage(mockCtx, httpRequest);
        verify(mockTraceHandler, mockTraceSpanLogsHandler);
    }
}
Also used : DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) RateSampler(com.wavefront.sdk.entities.tracing.sampling.RateSampler) SpanBytesEncoder(zipkin2.codec.SpanBytesEncoder) SpanSampler(com.wavefront.agent.sampler.SpanSampler) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ByteBuf(io.netty.buffer.ByteBuf) Span(wavefront.report.Span) Endpoint(zipkin2.Endpoint) NoopHealthCheckManager(com.wavefront.agent.channel.NoopHealthCheckManager) Test(org.junit.Test)

Example 32 with FRONTEND

use of zipkin2.TestObjects.FRONTEND in project zipkin by openzipkin.

the class StrictTraceIdTest method traces.

List<List<Span>> traces() {
    // 64-bit trace ID
    Span span1 = Span.newBuilder().traceId(CLIENT_SPAN.traceId().substring(16)).id("1").name("1").putTag("foo", "1").timestamp(TODAY * 1000L).localEndpoint(FRONTEND).build();
    // 128-bit trace ID prefixed by above
    Span span2 = span1.toBuilder().traceId(CLIENT_SPAN.traceId()).name("2").putTag("foo", "2").build();
    // Different 128-bit trace ID prefixed by above
    Span span3 = span1.toBuilder().traceId("1" + span1.traceId()).name("3").putTag("foo", "3").build();
    return new ArrayList<>(asList(asList(span1), asList(span2), asList(span3)));
}
Also used : ArrayList(java.util.ArrayList) Span(zipkin2.Span)

Example 33 with FRONTEND

use of zipkin2.TestObjects.FRONTEND in project zipkin by openzipkin.

the class V1SpanConverterTest method convert_ca.

@Test
public void convert_ca() {
    V1Span v1 = V1Span.newBuilder().traceId(1L).id(2L).addAnnotation(1472470996199000L, "sr", BACKEND).addBinaryAnnotation("ca", FRONTEND).build();
    Span v2 = Span.newBuilder().traceId("1").id("2").kind(Kind.SERVER).timestamp(1472470996199000L).localEndpoint(BACKEND).remoteEndpoint(FRONTEND).shared(true).build();
    assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 34 with FRONTEND

use of zipkin2.TestObjects.FRONTEND in project zipkin by openzipkin.

the class V1SpanConverterTest method convert_ca_incorrect_value.

@Test
public void convert_ca_incorrect_value() {
    V1Span v1 = V1Span.newBuilder().traceId(1L).id(2L).addAnnotation(1472470996199000L, "sr", BACKEND).addBinaryAnnotation("ca", "1", FRONTEND).build();
    Span v2 = Span.newBuilder().traceId("1").id("2").kind(Kind.SERVER).timestamp(1472470996199000L).localEndpoint(BACKEND).remoteEndpoint(FRONTEND).shared(true).build();
    assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 35 with FRONTEND

use of zipkin2.TestObjects.FRONTEND in project zipkin by openzipkin.

the class SpanConverterTest method producer_remote.

@Test
public void producer_remote() {
    Span v2 = Span.newBuilder().traceId("1").parentId("2").id("3").name("send").kind(Kind.PRODUCER).localEndpoint(FRONTEND).remoteEndpoint(kafka).timestamp(1472470996199000L).build();
    V1Span v1 = V1Span.newBuilder().traceId(1L).parentId(2L).id(3L).name("send").timestamp(1472470996199000L).addAnnotation(1472470996199000L, "ms", FRONTEND).addBinaryAnnotation("ma", kafka).build();
    assertThat(v2SpanConverter.convert(v2)).usingRecursiveComparison().isEqualTo(v1);
    assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Aggregations

Span (zipkin2.Span)50 Test (org.junit.Test)35 Endpoint (zipkin2.Endpoint)21 Test (org.junit.jupiter.api.Test)17 V1Span (zipkin2.v1.V1Span)12 TestObjects.newClientSpan (zipkin2.TestObjects.newClientSpan)6 NoopHealthCheckManager (com.wavefront.agent.channel.NoopHealthCheckManager)4 SpanSampler (com.wavefront.agent.sampler.SpanSampler)4 ByteBuf (io.netty.buffer.ByteBuf)4 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)4 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)4 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)4 Span (wavefront.report.Span)4 SpanBytesEncoder (zipkin2.codec.SpanBytesEncoder)4 Annotation (wavefront.report.Annotation)3 DurationSampler (com.wavefront.sdk.entities.tracing.sampling.DurationSampler)2 RateSampler (com.wavefront.sdk.entities.tracing.sampling.RateSampler)2 ArrayList (java.util.ArrayList)2 Arrays.asList (java.util.Arrays.asList)2 List (java.util.List)2