Search in sources :

Example 1 with Span

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

the class CustomTracingPortUnificationHandlerTest method reportsCorrectDuration.

@Test
public void reportsCorrectDuration() {
    WavefrontInternalReporter reporter = EasyMock.niceMock(WavefrontInternalReporter.class);
    expect(reporter.newDeltaCounter(anyObject())).andReturn(new DeltaCounter()).anyTimes();
    WavefrontHistogram histogram = EasyMock.niceMock(WavefrontHistogram.class);
    expect(reporter.newWavefrontHistogram(anyObject(), anyObject())).andReturn(histogram);
    Capture<Long> duration = newCapture();
    histogram.update(captureLong(duration));
    expectLastCall();
    ReportableEntityHandler<Span, String> handler = MockReportableEntityHandlerFactory.getMockTraceHandler();
    CustomTracingPortUnificationHandler subject = new CustomTracingPortUnificationHandler(null, null, null, null, null, null, handler, null, null, null, null, null, reporter, null, null, null);
    replay(reporter, histogram);
    Span span = getSpan();
    // milliseconds
    span.setDuration(1000);
    subject.report(span);
    verify(reporter, histogram);
    long value = duration.getValue();
    // microseconds
    assertEquals(1000000, value);
}
Also used : WavefrontInternalReporter(com.wavefront.internal.reporter.WavefrontInternalReporter) EasyMock.captureLong(org.easymock.EasyMock.captureLong) WavefrontHistogram(com.wavefront.internal_reporter_java.io.dropwizard.metrics5.WavefrontHistogram) Span(wavefront.report.Span) DeltaCounter(com.wavefront.internal_reporter_java.io.dropwizard.metrics5.DeltaCounter) Test(org.junit.Test)

Example 2 with Span

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

the class CustomTracingPortUnificationHandlerTest method getSpan.

@NotNull
private Span getSpan() {
    Span span = new Span();
    span.setAnnotations(ImmutableList.of(new Annotation("application", "application"), new Annotation("service", "service")));
    return span;
}
Also used : Span(wavefront.report.Span) Annotation(wavefront.report.Annotation) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with Span

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

the class TestUtils method parseSpan.

public static Span parseSpan(String line) {
    List<Span> out = Lists.newArrayListWithExpectedSize(1);
    new SpanDecoder("unknown").decode(line, out, "dummy");
    return out.get(0);
}
Also used : SpanDecoder(com.wavefront.ingester.SpanDecoder) Span(wavefront.report.Span)

Example 4 with Span

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

the class JaegerTChannelCollectorHandlerTest method testProtectedTagsProcessOverridesProxyConfig.

@Test
public void testProtectedTagsProcessOverridesProxyConfig() 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-processtag"), new Annotation("cluster", "cluster-processtag"), new Annotation("shard", "shard-processtag"))).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 customClusterProcessTag = new Tag("cluster", TagType.STRING);
    customClusterProcessTag.setVStr("cluster-processtag");
    Tag customShardProcessTag = new Tag("shard", TagType.STRING);
    customShardProcessTag.setVStr("shard-processtag");
    io.jaegertracing.thriftjava.Span span = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 2345678L, 0, "HTTP GET /", 1, startTime * 1000, 9 * 1000);
    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 5 with Span

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

the class JaegerTChannelCollectorHandlerTest method testAllProcessTagsPropagated.

@Test
public void testAllProcessTagsPropagated() throws Exception {
    reset(mockTraceHandler, mockTraceLogsHandler);
    mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(9).setName("HTTP GET /").setSource("source-spantag").setSpanId("00000000-0000-0000-0000-00000023cace").setTraceId("00000000-4996-02d2-0000-011f71fb04cb").setAnnotations(ImmutableList.of(new Annotation("ip", "10.0.0.1"), new Annotation("processTag1", "one"), new Annotation("processTag2", "two"), new Annotation("processTag3", "three"), new Annotation("jaegerSpanId", "23cace"), new Annotation("jaegerTraceId", "499602d20000011f71fb04cb"), new Annotation("service", "frontend"), new Annotation("parent", "00000000-0000-0000-0000-00000012d687"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"))).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 hostNameProcessTag = new Tag("hostname", TagType.STRING);
    hostNameProcessTag.setVStr("hostname-processtag");
    Tag customProcessTag1 = new Tag("processTag1", TagType.STRING);
    customProcessTag1.setVStr("one");
    Tag customProcessTag2 = new Tag("processTag2", TagType.STRING);
    customProcessTag2.setVStr("two");
    Tag customProcessTag3 = new Tag("processTag3", TagType.STRING);
    customProcessTag3.setVStr("three");
    Tag customSourceSpanTag = new Tag("source", TagType.STRING);
    customSourceSpanTag.setVStr("source-spantag");
    io.jaegertracing.thriftjava.Span span = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 2345678L, 1234567L, "HTTP GET /", 1, startTime * 1000, 9 * 1000);
    span.setTags(ImmutableList.of(customSourceSpanTag));
    Batch testBatch = new Batch();
    testBatch.process = new Process();
    testBatch.process.serviceName = "frontend";
    testBatch.process.setTags(ImmutableList.of(ipTag, hostNameProcessTag, customProcessTag1, customProcessTag2, customProcessTag3));
    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)

Aggregations

Span (wavefront.report.Span)49 Test (org.junit.Test)35 Annotation (wavefront.report.Annotation)34 SpanSampler (com.wavefront.agent.sampler.SpanSampler)18 TestUtils.parseSpan (com.wavefront.agent.TestUtils.parseSpan)15 Collectors (java.util.stream.Collectors)13 IOException (java.io.IOException)12 InputStream (java.io.InputStream)12 ReportableEntityPreprocessor (com.wavefront.agent.preprocessor.ReportableEntityPreprocessor)10 Batch (io.jaegertracing.thriftjava.Batch)10 ImmutableList (com.google.common.collect.ImmutableList)9 Tag (io.jaegertracing.thriftjava.Tag)9 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)9 Assert.assertEquals (org.junit.Assert.assertEquals)9 Assert.assertFalse (org.junit.Assert.assertFalse)9 Assert.assertTrue (org.junit.Assert.assertTrue)9 BeforeClass (org.junit.BeforeClass)9 RateSampler (com.wavefront.sdk.entities.tracing.sampling.RateSampler)8 List (java.util.List)8 Map (java.util.Map)8