Search in sources :

Example 21 with Annotation

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

the class PreprocessorSpanRulesTest method testSpanReplaceRegexRule.

@Test
public void testSpanReplaceRegexRule() {
    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 url=\"https://localhost:50051/style/foo/make?id=5145\" " + "1532012145123 1532012146234";
    SpanReplaceRegexTransformer rule;
    Span span;
    rule = new SpanReplaceRegexTransformer(SPAN_NAME, "test", "", null, null, false, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals("SpanName", span.getName());
    rule = new SpanReplaceRegexTransformer(SOURCE_NAME, "Name", "Z", null, null, false, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals("spanSourceZ", span.getSource());
    rule = new SpanReplaceRegexTransformer(SOURCE_NAME, "Name", "Z", "span.*", null, false, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals("spanSourceZ", span.getSource());
    rule = new SpanReplaceRegexTransformer(SOURCE_NAME, "Name", "Z", "no_match", null, false, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals("spanSourceName", span.getSource());
    rule = new SpanReplaceRegexTransformer(FOO, "234", "zzz", null, null, false, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals(ImmutableList.of("bar1-1zzz567890", "bar2-zzz5678901", "bar2-3456789012", "bar"), span.getAnnotations().stream().filter(x -> x.getKey().equals(FOO)).map(Annotation::getValue).collect(Collectors.toList()));
    rule = new SpanReplaceRegexTransformer(FOO, "901", "zzz", null, null, true, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals(ImmutableList.of("bar1-1234567890", "bar2-2345678zzz", "bar2-3456789012", "bar"), span.getAnnotations().stream().filter(x -> x.getKey().equals(FOO)).map(Annotation::getValue).collect(Collectors.toList()));
    rule = new SpanReplaceRegexTransformer(FOO, "\\d-\\d", "@", null, null, false, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals(ImmutableList.of("bar@234567890", "bar@345678901", "bar@456789012", "bar"), span.getAnnotations().stream().filter(x -> x.getKey().equals(FOO)).map(Annotation::getValue).collect(Collectors.toList()));
    rule = new SpanReplaceRegexTransformer(FOO, "\\d-\\d", "@", null, null, true, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals(ImmutableList.of("bar@234567890", "bar2-2345678901", "bar2-3456789012", "bar"), span.getAnnotations().stream().filter(x -> x.getKey().equals(FOO)).map(Annotation::getValue).collect(Collectors.toList()));
    rule = new SpanReplaceRegexTransformer(URL, "(https:\\/\\/.+\\/style\\/foo\\/make\\?id=)(.*)", "$1REDACTED", null, null, true, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals(ImmutableList.of("https://localhost:50051/style/foo/make?id=REDACTED"), span.getAnnotations().stream().filter(x -> x.getKey().equals(URL)).map(Annotation::getValue).collect(Collectors.toList()));
    rule = new SpanReplaceRegexTransformer("boo", "^.*$", "{{foo}}-{{spanName}}-{{sourceName}}{{}}", null, null, false, null, metrics);
    span = rule.apply(parseSpan(spanLine));
    assertEquals("bar1-1234567890-testSpanName-spanSourceName{{}}", span.getAnnotations().stream().filter(x -> x.getKey().equals("boo")).map(Annotation::getValue).findFirst().orElse("fail"));
}
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 22 with Annotation

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

the class JaegerPortUnificationHandlerTest method testJaegerPreprocessedDerivedMetrics.

/**
 * Test for derived metrics emitted from Jaeger trace listeners. Derived metrics should report
 * tag values post applying preprocessing rules to the span.
 */
@Test
public void testJaegerPreprocessedDerivedMetrics() throws Exception {
    Supplier<ReportableEntityPreprocessor> preprocessorSupplier = () -> {
        ReportableEntityPreprocessor preprocessor = new ReportableEntityPreprocessor();
        PreprocessorRuleMetrics preprocessorRuleMetrics = new PreprocessorRuleMetrics(null, null, null);
        preprocessor.forSpan().addTransformer(new SpanReplaceRegexTransformer(APPLICATION_TAG_KEY, "^Jaeger.*", PREPROCESSED_APPLICATION_TAG_VALUE, null, null, false, x -> true, preprocessorRuleMetrics));
        preprocessor.forSpan().addTransformer(new SpanReplaceRegexTransformer(SERVICE_TAG_KEY, "^test.*", PREPROCESSED_SERVICE_TAG_VALUE, null, null, false, x -> true, preprocessorRuleMetrics));
        preprocessor.forSpan().addTransformer(new SpanReplaceRegexTransformer("sourceName", "^jaeger.*", PREPROCESSED_SOURCE_VALUE, null, null, false, x -> true, preprocessorRuleMetrics));
        preprocessor.forSpan().addTransformer(new SpanReplaceRegexTransformer(CLUSTER_TAG_KEY, "^none.*", PREPROCESSED_CLUSTER_TAG_VALUE, null, null, false, x -> true, preprocessorRuleMetrics));
        preprocessor.forSpan().addTransformer(new SpanReplaceRegexTransformer(SHARD_TAG_KEY, "^none.*", PREPROCESSED_SHARD_TAG_VALUE, null, null, false, x -> true, preprocessorRuleMetrics));
        return preprocessor;
    };
    JaegerPortUnificationHandler handler = new JaegerPortUnificationHandler("14268", TokenAuthenticatorBuilder.create().build(), new NoopHealthCheckManager(), mockTraceHandler, mockTraceSpanLogsHandler, mockWavefrontSender, () -> false, () -> false, preprocessorSupplier, new SpanSampler(new RateSampler(1.0D), () -> null), null, null);
    io.jaegertracing.thriftjava.Span span1 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 1234567L, 0L, "HTTP GET", 1, startTime * 1000, 1234 * 1000);
    Batch testBatch = new Batch();
    testBatch.process = new Process();
    testBatch.process.serviceName = "testService";
    testBatch.setSpans(ImmutableList.of(span1));
    // Reset mock
    reset(mockCtx, mockTraceHandler, mockWavefrontSender);
    // Set Expectation
    Span expectedSpan1 = Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(1234).setName("HTTP GET").setSource(PREPROCESSED_SOURCE_VALUE).setSpanId("00000000-0000-0000-0000-00000012d687").setTraceId("00000000-4996-02d2-0000-011f71fb04cb").setAnnotations(ImmutableList.of(new Annotation("jaegerSpanId", "12d687"), new Annotation("jaegerTraceId", "499602d20000011f71fb04cb"), new Annotation("service", PREPROCESSED_SERVICE_TAG_VALUE), new Annotation("application", PREPROCESSED_APPLICATION_TAG_VALUE), new Annotation("cluster", PREPROCESSED_CLUSTER_TAG_VALUE), new Annotation("shard", PREPROCESSED_SHARD_TAG_VALUE))).build();
    mockTraceHandler.report(expectedSpan1);
    expectLastCall();
    Capture<HashMap<String, String>> tagsCapture = EasyMock.newCapture();
    mockWavefrontSender.sendMetric(eq(HEART_BEAT_METRIC), eq(1.0), anyLong(), eq(PREPROCESSED_SOURCE_VALUE), EasyMock.capture(tagsCapture));
    expectLastCall().anyTimes();
    replay(mockCtx, mockTraceHandler, mockWavefrontSender);
    ByteBuf content = Unpooled.copiedBuffer(new TSerializer().serialize(testBatch));
    FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "http://localhost:14268/api/traces", content, true);
    handler.handleHttpMessage(mockCtx, httpRequest);
    handler.run();
    verifyWithTimeout(500, mockTraceHandler, mockWavefrontSender);
    HashMap<String, String> tagsReturned = tagsCapture.getValue();
    assertEquals(PREPROCESSED_APPLICATION_TAG_VALUE, tagsReturned.get(APPLICATION_TAG_KEY));
    assertEquals(PREPROCESSED_SERVICE_TAG_VALUE, tagsReturned.get(SERVICE_TAG_KEY));
    assertEquals(PREPROCESSED_CLUSTER_TAG_VALUE, tagsReturned.get(CLUSTER_TAG_KEY));
    assertEquals(PREPROCESSED_SHARD_TAG_VALUE, tagsReturned.get(SHARD_TAG_KEY));
}
Also used : ReportableEntityPreprocessor(com.wavefront.agent.preprocessor.ReportableEntityPreprocessor) 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) HashMap(java.util.HashMap) SpanSampler(com.wavefront.agent.sampler.SpanSampler) Process(io.jaegertracing.thriftjava.Process) ByteBuf(io.netty.buffer.ByteBuf) Span(wavefront.report.Span) Annotation(wavefront.report.Annotation) PreprocessorRuleMetrics(com.wavefront.agent.preprocessor.PreprocessorRuleMetrics) TSerializer(org.apache.thrift.TSerializer) Batch(io.jaegertracing.thriftjava.Batch) NoopHealthCheckManager(com.wavefront.agent.channel.NoopHealthCheckManager) SpanReplaceRegexTransformer(com.wavefront.agent.preprocessor.SpanReplaceRegexTransformer) Test(org.junit.Test)

Example 23 with Annotation

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

the class JaegerPortUnificationHandlerTest method testJaegerPortUnificationHandler.

@Test
public void testJaegerPortUnificationHandler() throws Exception {
    reset(mockTraceHandler, mockTraceSpanLogsHandler, mockCtx);
    Span expectedSpan1 = Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(1234).setName("HTTP GET").setSource(DEFAULT_SOURCE).setSpanId("00000000-0000-0000-0000-00000012d687").setTraceId("00000000-4996-02d2-0000-011f71fb04cb").setAnnotations(ImmutableList.of(new Annotation("ip", "10.0.0.1"), new Annotation("jaegerSpanId", "12d687"), new Annotation("jaegerTraceId", "499602d20000011f71fb04cb"), new Annotation("service", "frontend"), new Annotation("component", "db"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("_spanLogs", "true"))).build();
    mockTraceHandler.report(expectedSpan1);
    expectLastCall();
    mockTraceSpanLogsHandler.report(SpanLogs.newBuilder().setCustomer("default").setSpanId("00000000-0000-0000-0000-00000012d687").setTraceId("00000000-4996-02d2-0000-011f71fb04cb").setLogs(ImmutableList.of(SpanLog.newBuilder().setTimestamp(startTime * 1000).setFields(ImmutableMap.of("event", "error", "exception", "NullPointerException")).build())).build());
    expectLastCall();
    mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(2345).setName("HTTP GET /").setSource(DEFAULT_SOURCE).setSpanId("00000000-0000-0000-0000-00000023cace").setTraceId("00000000-4996-02d2-0000-011f71fb04cb").setAnnotations(ImmutableList.of(new Annotation("ip", "10.0.0.1"), new Annotation("jaegerSpanId", "23cace"), new Annotation("jaegerTraceId", "499602d20000011f71fb04cb"), new Annotation("service", "frontend"), new Annotation("parent", "00000000-0000-0000-0000-00000012d687"), new Annotation("component", "db"), new Annotation("application", "Custom-JaegerApp"), new Annotation("cluster", "none"), new Annotation("shard", "none"))).build());
    expectLastCall();
    mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(3456).setName("HTTP GET /").setSource(DEFAULT_SOURCE).setSpanId("00000000-0000-0000-9a12-b85901d53397").setTraceId("00000000-0000-0000-fea4-87ee36e58cab").setAnnotations(ImmutableList.of(new Annotation("ip", "10.0.0.1"), new Annotation("jaegerSpanId", "9a12b85901d53397"), new Annotation("jaegerTraceId", "fea487ee36e58cab"), new Annotation("service", "frontend"), new Annotation("parent", "00000000-0000-0000-fea4-87ee36e58cab"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"))).build());
    expectLastCall();
    // Test filtering empty tags
    mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(3456).setName("HTTP GET /test").setSource(DEFAULT_SOURCE).setSpanId("00000000-0000-0000-0000-0051759bfc69").setTraceId("0000011e-ab2a-9944-0000-000049631900").setAnnotations(ImmutableList.of(new Annotation("ip", "10.0.0.1"), new Annotation("jaegerSpanId", "51759bfc69"), new Annotation("jaegerTraceId", "11eab2a99440000000049631900"), new Annotation("service", "frontend"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"))).build());
    expectLastCall();
    expect(mockCtx.write(EasyMock.isA(FullHttpResponse.class))).andReturn(null).anyTimes();
    replay(mockTraceHandler, mockTraceSpanLogsHandler, mockCtx);
    JaegerPortUnificationHandler handler = new JaegerPortUnificationHandler("14268", TokenAuthenticatorBuilder.create().build(), new NoopHealthCheckManager(), mockTraceHandler, mockTraceSpanLogsHandler, null, () -> false, () -> false, null, new SpanSampler(new RateSampler(1.0D), () -> null), null, null);
    Tag ipTag = new Tag("ip", TagType.STRING);
    ipTag.setVStr("10.0.0.1");
    Tag componentTag = new Tag("component", TagType.STRING);
    componentTag.setVStr("db");
    Tag customApplicationTag = new Tag("application", TagType.STRING);
    customApplicationTag.setVStr("Custom-JaegerApp");
    Tag emptyTag = new Tag("empty", TagType.STRING);
    emptyTag.setVStr("");
    io.jaegertracing.thriftjava.Span span1 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 1234567L, 0L, "HTTP GET", 1, startTime * 1000, 1234 * 1000);
    io.jaegertracing.thriftjava.Span span2 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 2345678L, 1234567L, "HTTP GET /", 1, startTime * 1000, 2345 * 1000);
    // check negative span IDs too
    io.jaegertracing.thriftjava.Span span3 = new io.jaegertracing.thriftjava.Span(-97803834702328661L, 0L, -7344605349865507945L, -97803834702328661L, "HTTP GET /", 1, startTime * 1000, 3456 * 1000);
    io.jaegertracing.thriftjava.Span span4 = new io.jaegertracing.thriftjava.Span(1231231232L, 1231232342340L, 349865507945L, 0, "HTTP GET /test", 1, startTime * 1000, 3456 * 1000);
    span1.setTags(ImmutableList.of(componentTag));
    span2.setTags(ImmutableList.of(componentTag, customApplicationTag));
    span4.setTags(ImmutableList.of(emptyTag));
    Tag tag1 = new Tag("event", TagType.STRING);
    tag1.setVStr("error");
    Tag tag2 = new Tag("exception", TagType.STRING);
    tag2.setVStr("NullPointerException");
    span1.setLogs(ImmutableList.of(new Log(startTime * 1000, ImmutableList.of(tag1, tag2))));
    Batch testBatch = new Batch();
    testBatch.process = new Process();
    testBatch.process.serviceName = "frontend";
    testBatch.process.setTags(ImmutableList.of(ipTag));
    testBatch.setSpans(ImmutableList.of(span1, span2, span3, span4));
    ByteBuf content = Unpooled.copiedBuffer(new TSerializer().serialize(testBatch));
    FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "http://localhost:14268/api/traces", 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) Log(io.jaegertracing.thriftjava.Log) SpanLog(wavefront.report.SpanLog) SpanSampler(com.wavefront.agent.sampler.SpanSampler) Process(io.jaegertracing.thriftjava.Process) ByteBuf(io.netty.buffer.ByteBuf) Span(wavefront.report.Span) Annotation(wavefront.report.Annotation) TSerializer(org.apache.thrift.TSerializer) Batch(io.jaegertracing.thriftjava.Batch) NoopHealthCheckManager(com.wavefront.agent.channel.NoopHealthCheckManager) Tag(io.jaegertracing.thriftjava.Tag) Test(org.junit.Test)

Example 24 with Annotation

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

the class JaegerTChannelCollectorHandlerTest method testProtectedTagsSpanOverridesProcess.

@Test
public void testProtectedTagsSpanOverridesProcess() throws Exception {
    // cluster, shard and service are special tags, because they're indexed by wavefront
    // The priority order is:
    // Span Level > Process Level > Proxy Level > Default
    reset(mockTraceHandler, mockTraceLogsHandler);
    mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(9).setName("HTTP GET /").setSource("source-processtag").setSpanId("00000000-0000-0000-0000-00000023cace").setTraceId("00000000-4996-02d2-0000-011f71fb04cb").setAnnotations(ImmutableList.of(new Annotation("ip", "10.0.0.1"), new Annotation("jaegerSpanId", "23cace"), new Annotation("jaegerTraceId", "499602d20000011f71fb04cb"), new Annotation("service", "frontend"), new Annotation("application", "application-spantag"), new Annotation("cluster", "cluster-spantag"), new Annotation("shard", "shard-spantag"))).build());
    expectLastCall();
    replay(mockTraceHandler, mockTraceLogsHandler);
    JaegerTChannelCollectorHandler handler = new JaegerTChannelCollectorHandler("9876", mockTraceHandler, mockTraceLogsHandler, null, () -> false, () -> false, null, new SpanSampler(new RateSampler(1.0D), () -> null), null, null);
    Tag ipTag = new Tag("ip", TagType.STRING);
    ipTag.setVStr("10.0.0.1");
    Tag sourceProcessTag = new Tag("source", TagType.STRING);
    sourceProcessTag.setVStr("source-processtag");
    Tag customApplicationProcessTag = new Tag("application", TagType.STRING);
    customApplicationProcessTag.setVStr("application-processtag");
    Tag customApplicationSpanTag = new Tag("application", TagType.STRING);
    customApplicationSpanTag.setVStr("application-spantag");
    Tag customClusterProcessTag = new Tag("cluster", TagType.STRING);
    customClusterProcessTag.setVStr("cluster-processtag");
    Tag customClusterSpanTag = new Tag("cluster", TagType.STRING);
    customClusterSpanTag.setVStr("cluster-spantag");
    Tag customShardProcessTag = new Tag("shard", TagType.STRING);
    customShardProcessTag.setVStr("shard-processtag");
    Tag customShardSpanTag = new Tag("shard", TagType.STRING);
    customShardSpanTag.setVStr("shard-spantag");
    io.jaegertracing.thriftjava.Span span = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 2345678L, 0, "HTTP GET /", 1, startTime * 1000, 9 * 1000);
    span.setTags(ImmutableList.of(customApplicationSpanTag, customClusterSpanTag, customShardSpanTag));
    Batch testBatch = new Batch();
    testBatch.process = new Process();
    testBatch.process.serviceName = "frontend";
    testBatch.process.setTags(ImmutableList.of(ipTag, sourceProcessTag, customApplicationProcessTag, customClusterProcessTag, customShardProcessTag));
    testBatch.setSpans(ImmutableList.of(span));
    Collector.submitBatches_args batches = new Collector.submitBatches_args();
    batches.addToBatches(testBatch);
    ThriftRequest<Collector.submitBatches_args> request = new ThriftRequest.Builder<Collector.submitBatches_args>("jaeger-collector", "Collector::submitBatches").setBody(batches).build();
    handler.handleImpl(request);
    verify(mockTraceHandler, mockTraceLogsHandler);
}
Also used : RateSampler(com.wavefront.sdk.entities.tracing.sampling.RateSampler) SpanSampler(com.wavefront.agent.sampler.SpanSampler) Process(io.jaegertracing.thriftjava.Process) Span(wavefront.report.Span) Annotation(wavefront.report.Annotation) Batch(io.jaegertracing.thriftjava.Batch) Collector(io.jaegertracing.thriftjava.Collector) Tag(io.jaegertracing.thriftjava.Tag) Test(org.junit.Test)

Example 25 with Annotation

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

the class ZipkinPortUnificationHandlerTest method doMockLifecycle.

private void doMockLifecycle(ReportableEntityHandler<Span, String> mockTraceHandler, ReportableEntityHandler<SpanLogs, String> mockTraceSpanLogsHandler) {
    // Reset mock
    reset(mockTraceHandler, mockTraceSpanLogsHandler);
    // Set Expectation
    mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(1234).setName("getservice").setSource(DEFAULT_SOURCE).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", "ProxyLevelAppTag"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("ipv4", "10.0.0.1"))).build());
    expectLastCall();
    Span span1 = Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(2234).setName("getbackendservice").setSource(DEFAULT_SOURCE).setSpanId("00000000-0000-0000-d6ab-73f8a3930ae8").setTraceId("00000000-0000-0000-2822-889fe47043bd").setAnnotations(ImmutableList.of(new Annotation("zipkinSpanId", "d6ab73f8a3930ae8"), new Annotation("zipkinTraceId", "2822889fe47043bd"), new Annotation("parent", "00000000-0000-0000-2822-889fe47043bd"), new Annotation("span.kind", "server"), new Annotation("_spanSecondaryId", "server"), new Annotation("service", "backend"), new Annotation("component", "jersey-server"), new Annotation("http.method", "GET"), new Annotation("http.status_code", "200"), new Annotation("http.url", "none+h2c://localhost:9000/api"), new Annotation("application", "SpanLevelAppTag"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("ipv4", "10.0.0.1"), new Annotation("_spanLogs", "true"))).build();
    mockTraceHandler.report(span1);
    expectLastCall();
    Span span2 = Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(2234).setName("getbackendservice2").setSource(DEFAULT_SOURCE).setTraceId("00000000-0000-0000-2822-889fe47043bd").setSpanId("00000000-0000-0000-d6ab-73f8a3930ae8").setAnnotations(ImmutableList.of(new Annotation("zipkinSpanId", "d6ab73f8a3930ae8"), new Annotation("zipkinTraceId", "2822889fe47043bd"), new Annotation("span.kind", "client"), new Annotation("_spanSecondaryId", "client"), new Annotation("service", "backend"), new Annotation("component", "jersey-server"), new Annotation("http.method", "GET"), new Annotation("http.status_code", "200"), new Annotation("http.url", "none+h2c://localhost:9000/api"), new Annotation("application", "SpanLevelAppTag"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("ipv4", "10.0.0.1"), new Annotation("_spanLogs", "true"))).build();
    mockTraceHandler.report(span2);
    expectLastCall();
    mockTraceSpanLogsHandler.report(SpanLogs.newBuilder().setCustomer("default").setTraceId("00000000-0000-0000-2822-889fe47043bd").setSpanId("00000000-0000-0000-d6ab-73f8a3930ae8").setSpanSecondaryId("server").setLogs(ImmutableList.of(SpanLog.newBuilder().setTimestamp(startTime * 1000).setFields(ImmutableMap.of("annotation", "start processing")).build())).build());
    expectLastCall();
    mockTraceSpanLogsHandler.report(SpanLogs.newBuilder().setCustomer("default").setTraceId("00000000-0000-0000-2822-889fe47043bd").setSpanId("00000000-0000-0000-d6ab-73f8a3930ae8").setSpanSecondaryId("client").setLogs(ImmutableList.of(SpanLog.newBuilder().setTimestamp(startTime * 1000).setFields(ImmutableMap.of("annotation", "start processing")).build())).build());
    expectLastCall();
    // Replay
    replay(mockTraceHandler, mockTraceSpanLogsHandler);
}
Also used : Span(wavefront.report.Span) Annotation(wavefront.report.Annotation)

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