Search in sources :

Example 46 with Annotation

use of wavefront.report.Annotation in project java by wavefrontHQ.

the class ZipkinPortUnificationHandlerTest method testZipkinCustomSource.

@Test
public void testZipkinCustomSource() throws Exception {
    ZipkinPortUnificationHandler handler = new ZipkinPortUnificationHandler("9411", new NoopHealthCheckManager(), mockTraceHandler, mockTraceSpanLogsHandler, null, () -> false, () -> false, null, new SpanSampler(new RateSampler(1.0D), () -> null), null, null);
    // take care of mocks.
    // Reset mock
    reset(mockTraceHandler, mockTraceSpanLogsHandler);
    // Set Expectation
    mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(9).setName("getservice").setSource("customZipkinSource").setSpanId("00000000-0000-0000-2822-889fe47043bd").setTraceId("00000000-0000-0000-2822-889fe47043bd").setAnnotations(ImmutableList.of(new Annotation("zipkinSpanId", "2822889fe47043bd"), new Annotation("zipkinTraceId", "2822889fe47043bd"), new Annotation("span.kind", "server"), new Annotation("service", "frontend"), new Annotation("http.method", "GET"), new Annotation("http.status_code", "200"), new Annotation("http.url", "none+h1c://localhost:8881/"), new Annotation("application", "Zipkin"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("ipv4", "10.0.0.1"))).build());
    expectLastCall();
    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(9 * 1000).localEndpoint(localEndpoint1).putTag("http.method", "GET").putTag("http.url", "none+h1c://localhost:8881/").putTag("http.status_code", "200").putTag("source", "customZipkinSource").build();
    List<zipkin2.Span> zipkinSpanList = ImmutableList.of(spanServer1);
    SpanBytesEncoder encoder = SpanBytesEncoder.values()[1];
    ByteBuf content = Unpooled.copiedBuffer(encoder.encodeList(zipkinSpanList));
    replay(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) Annotation(wavefront.report.Annotation) Endpoint(zipkin2.Endpoint) NoopHealthCheckManager(com.wavefront.agent.channel.NoopHealthCheckManager) Test(org.junit.Test)

Example 47 with Annotation

use of wavefront.report.Annotation in project java by wavefrontHQ.

the class PreprocessorSpanRulesTest method testSpanAddAnnotationIfNotExistsRule.

@Test
public void testSpanAddAnnotationIfNotExistsRule() {
    String spanLine = "\"testSpanName\" \"source\"=\"spanSourceName\" " + "\"spanId\"=\"4217104a-690d-4927-baff-d9aa779414c2\" \"traceId\"=\"d5355bf7-fc8d-48d1-b761-75b170f396e0\" " + "\"foo\"=\"bar1-1234567890\" \"foo\"=\"bar2-1234567890\" \"foo\"=\"bar2-2345678901\" \"foo\"=\"baz\" " + "1532012145123 1532012146234";
    SpanAddAnnotationTransformer rule;
    Span span;
    rule = new SpanAddAnnotationIfNotExistsTransformer(FOO, "baz2", null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals(ImmutableList.of("bar1-1234567890", "bar2-1234567890", "bar2-2345678901", "baz"), span.getAnnotations().stream().filter(x -> x.getKey().equals(FOO)).map(Annotation::getValue).collect(Collectors.toList()));
    rule = new SpanAddAnnotationIfNotExistsTransformer("foo2", "bar2", null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals(5, span.getAnnotations().size());
    assertEquals(new Annotation("foo2", "bar2"), span.getAnnotations().get(4));
}
Also used : Annotation(wavefront.report.Annotation) BeforeClass(org.junit.BeforeClass) ImmutableList(com.google.common.collect.ImmutableList) Assert.assertFalse(org.junit.Assert.assertFalse) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) Span(wavefront.report.Span) Collectors(java.util.stream.Collectors) TestUtils.parseSpan(com.wavefront.agent.TestUtils.parseSpan) Assert.assertEquals(org.junit.Assert.assertEquals) InputStream(java.io.InputStream) Span(wavefront.report.Span) TestUtils.parseSpan(com.wavefront.agent.TestUtils.parseSpan) Annotation(wavefront.report.Annotation) Test(org.junit.Test)

Example 48 with Annotation

use of wavefront.report.Annotation in project java by wavefrontHQ.

the class PreprocessorSpanRulesTest method testSpanForceLowercaseRule.

@Test
public void testSpanForceLowercaseRule() {
    String spanLine = "testSpanName source=spanSourceName spanId=4217104a-690d-4927-baff-d9aa779414c2 " + "traceId=d5355bf7-fc8d-48d1-b761-75b170f396e0 foo=BAR1-1234567890 foo=BAR2-2345678901 foo=bAr2-3456789012 " + "foo=baR boo=baz 1532012145123 1532012146234";
    SpanForceLowercaseTransformer rule;
    Span span;
    rule = new SpanForceLowercaseTransformer(SOURCE_NAME, null, false, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals("spansourcename", span.getSource());
    rule = new SpanForceLowercaseTransformer(SPAN_NAME, null, false, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals("testspanname", span.getName());
    rule = new SpanForceLowercaseTransformer(SPAN_NAME, "test.*", false, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals("testspanname", span.getName());
    rule = new SpanForceLowercaseTransformer(SPAN_NAME, "nomatch", false, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals("testSpanName", span.getName());
    rule = new SpanForceLowercaseTransformer(FOO, null, false, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals(ImmutableList.of("bar1-1234567890", "bar2-2345678901", "bar2-3456789012", "bar"), span.getAnnotations().stream().filter(x -> x.getKey().equals(FOO)).map(Annotation::getValue).collect(Collectors.toList()));
    rule = new SpanForceLowercaseTransformer(FOO, null, true, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals(ImmutableList.of("bar1-1234567890", "BAR2-2345678901", "bAr2-3456789012", "baR"), span.getAnnotations().stream().filter(x -> x.getKey().equals(FOO)).map(Annotation::getValue).collect(Collectors.toList()));
    rule = new SpanForceLowercaseTransformer(FOO, "BAR.*", false, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals(ImmutableList.of("bar1-1234567890", "bar2-2345678901", "bAr2-3456789012", "baR"), span.getAnnotations().stream().filter(x -> x.getKey().equals(FOO)).map(Annotation::getValue).collect(Collectors.toList()));
    rule = new SpanForceLowercaseTransformer(FOO, "no_match", false, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals(ImmutableList.of("BAR1-1234567890", "BAR2-2345678901", "bAr2-3456789012", "baR"), span.getAnnotations().stream().filter(x -> x.getKey().equals(FOO)).map(Annotation::getValue).collect(Collectors.toList()));
}
Also used : Annotation(wavefront.report.Annotation) BeforeClass(org.junit.BeforeClass) ImmutableList(com.google.common.collect.ImmutableList) Assert.assertFalse(org.junit.Assert.assertFalse) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) Span(wavefront.report.Span) Collectors(java.util.stream.Collectors) TestUtils.parseSpan(com.wavefront.agent.TestUtils.parseSpan) Assert.assertEquals(org.junit.Assert.assertEquals) InputStream(java.io.InputStream) Span(wavefront.report.Span) TestUtils.parseSpan(com.wavefront.agent.TestUtils.parseSpan) Annotation(wavefront.report.Annotation) Test(org.junit.Test)

Example 49 with Annotation

use of wavefront.report.Annotation in project java by wavefrontHQ.

the class PreprocessorSpanRulesTest method testSpanAddAnnotationRule.

@Test
public void testSpanAddAnnotationRule() {
    String spanLine = "\"testSpanName\" \"source\"=\"spanSourceName\" " + "\"spanId\"=\"4217104a-690d-4927-baff-d9aa779414c2\" \"traceId\"=\"d5355bf7-fc8d-48d1-b761-75b170f396e0\" " + "\"foo\"=\"bar1-1234567890\" \"foo\"=\"bar2-1234567890\" \"foo\"=\"bar2-2345678901\" \"foo\"=\"baz\" " + "1532012145123 1532012146234";
    SpanAddAnnotationTransformer rule;
    Span span;
    rule = new SpanAddAnnotationTransformer(FOO, "baz2", null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals(ImmutableList.of("bar1-1234567890", "bar2-1234567890", "bar2-2345678901", "baz", "baz2"), span.getAnnotations().stream().filter(x -> x.getKey().equals(FOO)).map(Annotation::getValue).collect(Collectors.toList()));
}
Also used : Annotation(wavefront.report.Annotation) BeforeClass(org.junit.BeforeClass) ImmutableList(com.google.common.collect.ImmutableList) Assert.assertFalse(org.junit.Assert.assertFalse) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) Span(wavefront.report.Span) Collectors(java.util.stream.Collectors) TestUtils.parseSpan(com.wavefront.agent.TestUtils.parseSpan) Assert.assertEquals(org.junit.Assert.assertEquals) InputStream(java.io.InputStream) Span(wavefront.report.Span) TestUtils.parseSpan(com.wavefront.agent.TestUtils.parseSpan) Annotation(wavefront.report.Annotation) Test(org.junit.Test)

Example 50 with Annotation

use of wavefront.report.Annotation in project java by wavefrontHQ.

the class PreprocessorSpanRulesTest method testSpanDropAnnotationRule.

@Test
public void testSpanDropAnnotationRule() {
    String spanLine = "\"testSpanName\" \"source\"=\"spanSourceName\" " + "\"spanId\"=\"4217104a-690d-4927-baff-d9aa779414c2\" \"traceId\"=\"d5355bf7-fc8d-48d1-b761-75b170f396e0\" " + "\"foo\"=\"bar1-1234567890\" \"foo\"=\"bar2-1234567890\" \"foo\"=\"bar2-2345678901\" \"foo\"=\"baz\" " + "1532012145123 1532012146234";
    SpanDropAnnotationTransformer rule;
    Span span;
    // drop first annotation with key = "foo"
    rule = new SpanDropAnnotationTransformer(FOO, null, true, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals(ImmutableList.of("bar2-1234567890", "bar2-2345678901", "baz"), span.getAnnotations().stream().filter(x -> x.getKey().equals(FOO)).map(Annotation::getValue).collect(Collectors.toList()));
    // drop all annotations with key = "foo"
    rule = new SpanDropAnnotationTransformer(FOO, null, false, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals(ImmutableList.of(), span.getAnnotations().stream().filter(x -> x.getKey().equals(FOO)).map(Annotation::getValue).collect(Collectors.toList()));
    // drop all annotations with key = "foo" and value matching bar2.*
    rule = new SpanDropAnnotationTransformer(FOO, "bar2.*", false, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals(ImmutableList.of("bar1-1234567890", "baz"), span.getAnnotations().stream().filter(x -> x.getKey().equals(FOO)).map(Annotation::getValue).collect(Collectors.toList()));
    // drop first annotation with key = "foo" and value matching bar2.*
    rule = new SpanDropAnnotationTransformer(FOO, "bar2.*", true, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals(ImmutableList.of("bar1-1234567890", "bar2-2345678901", "baz"), span.getAnnotations().stream().filter(x -> x.getKey().equals(FOO)).map(Annotation::getValue).collect(Collectors.toList()));
}
Also used : Annotation(wavefront.report.Annotation) BeforeClass(org.junit.BeforeClass) ImmutableList(com.google.common.collect.ImmutableList) Assert.assertFalse(org.junit.Assert.assertFalse) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) Span(wavefront.report.Span) Collectors(java.util.stream.Collectors) TestUtils.parseSpan(com.wavefront.agent.TestUtils.parseSpan) Assert.assertEquals(org.junit.Assert.assertEquals) InputStream(java.io.InputStream) Span(wavefront.report.Span) TestUtils.parseSpan(com.wavefront.agent.TestUtils.parseSpan) Annotation(wavefront.report.Annotation) Test(org.junit.Test)

Aggregations

Annotation (wavefront.report.Annotation)62 Test (org.junit.Test)45 Span (wavefront.report.Span)36 SpanSampler (com.wavefront.agent.sampler.SpanSampler)34 RateSampler (com.wavefront.sdk.entities.tracing.sampling.RateSampler)23 Collectors (java.util.stream.Collectors)13 ByteString (com.google.protobuf.ByteString)12 Batch (io.jaegertracing.thriftjava.Batch)12 Tag (io.jaegertracing.thriftjava.Tag)12 Model (io.opentelemetry.exporters.jaeger.proto.api_v2.Model)12 TestUtils.parseSpan (com.wavefront.agent.TestUtils.parseSpan)11 Process (io.jaegertracing.thriftjava.Process)11 IOException (java.io.IOException)11 ByteBuffer (java.nio.ByteBuffer)11 Collector (io.opentelemetry.exporters.jaeger.proto.api_v2.Collector)10 ImmutableList (com.google.common.collect.ImmutableList)9 DurationSampler (com.wavefront.sdk.entities.tracing.sampling.DurationSampler)9 Collector (io.jaegertracing.thriftjava.Collector)9 InputStream (java.io.InputStream)9 Nullable (javax.annotation.Nullable)9