Search in sources :

Example 11 with DurationSampler

use of com.wavefront.sdk.entities.tracing.sampling.DurationSampler in project java by wavefrontHQ.

the class JaegerTChannelCollectorHandlerTest method testJaegerDurationSampler.

@Test
public void testJaegerDurationSampler() throws Exception {
    reset(mockTraceHandler, mockTraceLogsHandler);
    Span expectedSpan2 = Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(9).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("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("_spanLogs", "true"))).build();
    mockTraceHandler.report(expectedSpan2);
    expectLastCall();
    mockTraceLogsHandler.report(SpanLogs.newBuilder().setCustomer("default").setSpanId("00000000-0000-0000-0000-00000023cace").setTraceId("00000000-4996-02d2-0000-011f71fb04cb").setLogs(ImmutableList.of(SpanLog.newBuilder().setTimestamp(startTime * 1000).setFields(ImmutableMap.of("event", "error", "exception", "NullPointerException")).build())).build());
    expectLastCall();
    replay(mockTraceHandler, mockTraceLogsHandler);
    JaegerTChannelCollectorHandler handler = new JaegerTChannelCollectorHandler("9876", mockTraceHandler, mockTraceLogsHandler, null, () -> false, () -> false, null, new SpanSampler(new DurationSampler(5), () -> null), null, null);
    Tag ipTag = new Tag("ip", TagType.STRING);
    ipTag.setVStr("10.0.0.1");
    io.jaegertracing.thriftjava.Span span1 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 1234567L, 0L, "HTTP GET", 1, startTime * 1000, 4 * 1000);
    io.jaegertracing.thriftjava.Span span2 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 2345678L, 1234567L, "HTTP GET /", 1, startTime * 1000, 9 * 1000);
    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))));
    span2.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));
    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 : SpanLog(wavefront.report.SpanLog) Log(io.jaegertracing.thriftjava.Log) SpanSampler(com.wavefront.agent.sampler.SpanSampler) Process(io.jaegertracing.thriftjava.Process) Span(wavefront.report.Span) Annotation(wavefront.report.Annotation) DurationSampler(com.wavefront.sdk.entities.tracing.sampling.DurationSampler) Batch(io.jaegertracing.thriftjava.Batch) Collector(io.jaegertracing.thriftjava.Collector) Tag(io.jaegertracing.thriftjava.Tag) Test(org.junit.Test)

Aggregations

DurationSampler (com.wavefront.sdk.entities.tracing.sampling.DurationSampler)11 Test (org.junit.Test)11 Annotation (wavefront.report.Annotation)9 Span (wavefront.report.Span)8 SpanSampler (com.wavefront.agent.sampler.SpanSampler)7 SpanSamplingPolicy (com.wavefront.api.agent.SpanSamplingPolicy)4 ByteString (com.google.protobuf.ByteString)2 NoopHealthCheckManager (com.wavefront.agent.channel.NoopHealthCheckManager)2 Batch (io.jaegertracing.thriftjava.Batch)2 Collector (io.jaegertracing.thriftjava.Collector)2 Log (io.jaegertracing.thriftjava.Log)2 Process (io.jaegertracing.thriftjava.Process)2 Tag (io.jaegertracing.thriftjava.Tag)2 ByteBuf (io.netty.buffer.ByteBuf)2 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)2 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)2 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)2 Collector (io.opentelemetry.exporters.jaeger.proto.api_v2.Collector)2 Model (io.opentelemetry.exporters.jaeger.proto.api_v2.Model)2 ByteBuffer (java.nio.ByteBuffer)2