Search in sources :

Example 11 with SpanSampler

use of com.wavefront.agent.sampler.SpanSampler in project java by wavefrontHQ.

the class JaegerGrpcCollectorHandlerTest method testJaegerGrpcCollector.

@Test
public void testJaegerGrpcCollector() throws Exception {
    reset(mockTraceHandler, mockTraceLogsHandler);
    mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(1000).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("service", "frontend"), new Annotation("component", "db"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("_spanLogs", "true"))).build());
    expectLastCall();
    mockTraceLogsHandler.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(2000).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("service", "frontend"), new Annotation("component", "db"), new Annotation("application", "Custom-JaegerApp"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("parent", "00000000-0000-0000-0000-00000012d687"))).build());
    expectLastCall();
    mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(2000).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("service", "frontend"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("parent", "00000000-0000-0000-fea4-87ee36e58cab"))).build());
    expectLastCall();
    // Test filtering empty tags
    mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(2000).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("service", "frontend"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"))).build());
    expectLastCall();
    replay(mockTraceHandler, mockTraceLogsHandler);
    JaegerGrpcCollectorHandler handler = new JaegerGrpcCollectorHandler("9876", mockTraceHandler, mockTraceLogsHandler, null, () -> false, () -> false, null, new SpanSampler(new RateSampler(1.0D), () -> null), null, null);
    Model.KeyValue ipTag = Model.KeyValue.newBuilder().setKey("ip").setVStr("10.0.0.1").setVType(Model.ValueType.STRING).build();
    Model.KeyValue componentTag = Model.KeyValue.newBuilder().setKey("component").setVStr("db").setVType(Model.ValueType.STRING).build();
    Model.KeyValue customApplicationTag = Model.KeyValue.newBuilder().setKey("application").setVStr("Custom-JaegerApp").setVType(Model.ValueType.STRING).build();
    Model.KeyValue emptyTag = Model.KeyValue.newBuilder().setKey("empty").setVStr("").setVType(Model.ValueType.STRING).build();
    ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES * 2);
    buffer.putLong(1234567890L);
    buffer.putLong(1234567890123L);
    ByteString traceId = ByteString.copyFrom(buffer.array());
    buffer = ByteBuffer.allocate(Long.BYTES * 2);
    buffer.putLong(0L);
    buffer.putLong(-97803834702328661L);
    ByteString trace3Id = ByteString.copyFrom(buffer.array());
    buffer = ByteBuffer.allocate(Long.BYTES * 2);
    buffer.putLong(1231232342340L);
    buffer.putLong(1231231232L);
    ByteString trace4Id = ByteString.copyFrom(buffer.array());
    buffer = ByteBuffer.allocate(Long.BYTES);
    buffer.putLong(1234567L);
    ByteString span1Id = ByteString.copyFrom(buffer.array());
    buffer = ByteBuffer.allocate(Long.BYTES);
    buffer.putLong(2345678L);
    ByteString span2Id = ByteString.copyFrom(buffer.array());
    buffer = ByteBuffer.allocate(Long.BYTES);
    buffer.putLong(-7344605349865507945L);
    ByteString span3Id = ByteString.copyFrom(buffer.array());
    buffer = ByteBuffer.allocate(Long.BYTES);
    buffer.putLong(-97803834702328661L);
    ByteString span3ParentId = ByteString.copyFrom(buffer.array());
    buffer = ByteBuffer.allocate(Long.BYTES);
    buffer.putLong(349865507945L);
    ByteString span4Id = ByteString.copyFrom(buffer.array());
    Model.Span span1 = Model.Span.newBuilder().setTraceId(traceId).setSpanId(span1Id).setDuration(Duration.newBuilder().setSeconds(1L).build()).setOperationName("HTTP GET").setStartTime(fromMillis(startTime)).addTags(componentTag).addLogs(Model.Log.newBuilder().addFields(Model.KeyValue.newBuilder().setKey("event").setVStr("error").setVType(Model.ValueType.STRING).build()).addFields(Model.KeyValue.newBuilder().setKey("exception").setVStr("NullPointerException").setVType(Model.ValueType.STRING).build()).setTimestamp(fromMillis(startTime))).build();
    Model.Span span2 = Model.Span.newBuilder().setTraceId(traceId).setSpanId(span2Id).setDuration(Duration.newBuilder().setSeconds(2L).build()).setOperationName("HTTP GET /").setStartTime(fromMillis(startTime)).addTags(componentTag).addTags(customApplicationTag).addReferences(Model.SpanRef.newBuilder().setRefType(Model.SpanRefType.CHILD_OF).setSpanId(span1Id).setTraceId(traceId).build()).build();
    // check negative span IDs too
    Model.Span span3 = Model.Span.newBuilder().setTraceId(trace3Id).setSpanId(span3Id).setDuration(Duration.newBuilder().setSeconds(2L).build()).setOperationName("HTTP GET /").setStartTime(fromMillis(startTime)).addReferences(Model.SpanRef.newBuilder().setRefType(Model.SpanRefType.CHILD_OF).setSpanId(span3ParentId).setTraceId(traceId).build()).build();
    Model.Span span4 = Model.Span.newBuilder().setTraceId(trace4Id).setSpanId(span4Id).setDuration(Duration.newBuilder().setSeconds(2L).build()).setOperationName("HTTP GET /test").setStartTime(fromMillis(startTime)).addTags(emptyTag).build();
    Model.Batch testBatch = Model.Batch.newBuilder().setProcess(Model.Process.newBuilder().setServiceName("frontend").addTags(ipTag).build()).addAllSpans(ImmutableList.of(span1, span2, span3, span4)).build();
    Collector.PostSpansRequest batches = Collector.PostSpansRequest.newBuilder().setBatch(testBatch).build();
    handler.postSpans(batches, emptyStreamObserver);
    verify(mockTraceHandler, mockTraceLogsHandler);
}
Also used : RateSampler(com.wavefront.sdk.entities.tracing.sampling.RateSampler) ByteString(com.google.protobuf.ByteString) SpanSampler(com.wavefront.agent.sampler.SpanSampler) Model(io.opentelemetry.exporters.jaeger.proto.api_v2.Model) Collector(io.opentelemetry.exporters.jaeger.proto.api_v2.Collector) ByteBuffer(java.nio.ByteBuffer) Annotation(wavefront.report.Annotation) Test(org.junit.Test)

Example 12 with SpanSampler

use of com.wavefront.agent.sampler.SpanSampler in project java by wavefrontHQ.

the class JaegerGrpcCollectorHandlerTest method testApplicationTagPriority.

@Test
public void testApplicationTagPriority() throws Exception {
    reset(mockTraceHandler, mockTraceLogsHandler);
    // Span to verify span level tags precedence
    mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(1000).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("service", "frontend"), new Annotation("component", "db"), new Annotation("application", "SpanLevelAppTag"), new Annotation("cluster", "none"), new Annotation("shard", "none"))).build());
    expectLastCall();
    // Span to verify process level tags precedence
    mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(2000).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("service", "frontend"), new Annotation("component", "db"), new Annotation("application", "ProcessLevelAppTag"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("parent", "00000000-0000-0000-0000-00000012d687"))).build());
    expectLastCall();
    // Span to verify Proxy level tags precedence
    mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(3000).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("service", "frontend"), new Annotation("application", "ProxyLevelAppTag"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("parent", "00000000-0000-0000-fea4-87ee36e58cab"))).build());
    expectLastCall();
    replay(mockTraceHandler, mockTraceLogsHandler);
    // Verify span level "application" tags precedence
    JaegerGrpcCollectorHandler handler = new JaegerGrpcCollectorHandler("9876", mockTraceHandler, mockTraceLogsHandler, null, () -> false, () -> false, null, new SpanSampler(new RateSampler(1.0D), () -> null), "ProxyLevelAppTag", null);
    Model.KeyValue ipTag = Model.KeyValue.newBuilder().setKey("ip").setVStr("10.0.0.1").setVType(Model.ValueType.STRING).build();
    Model.KeyValue componentTag = Model.KeyValue.newBuilder().setKey("component").setVStr("db").setVType(Model.ValueType.STRING).build();
    Model.KeyValue spanLevelAppTag = Model.KeyValue.newBuilder().setKey("application").setVStr("SpanLevelAppTag").setVType(Model.ValueType.STRING).build();
    Model.KeyValue processLevelAppTag = Model.KeyValue.newBuilder().setKey("application").setVStr("ProcessLevelAppTag").setVType(Model.ValueType.STRING).build();
    ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES * 2);
    buffer.putLong(1234567890L);
    buffer.putLong(1234567890123L);
    ByteString traceId = ByteString.copyFrom(buffer.array());
    buffer = ByteBuffer.allocate(Long.BYTES * 2);
    buffer.putLong(0L);
    buffer.putLong(-97803834702328661L);
    ByteString trace2Id = ByteString.copyFrom(buffer.array());
    buffer = ByteBuffer.allocate(Long.BYTES);
    buffer.putLong(1234567L);
    ByteString span1Id = ByteString.copyFrom(buffer.array());
    buffer = ByteBuffer.allocate(Long.BYTES);
    buffer.putLong(2345678L);
    ByteString span2Id = ByteString.copyFrom(buffer.array());
    buffer = ByteBuffer.allocate(Long.BYTES);
    buffer.putLong(-7344605349865507945L);
    ByteString span3Id = ByteString.copyFrom(buffer.array());
    buffer = ByteBuffer.allocate(Long.BYTES);
    buffer.putLong(-97803834702328661L);
    ByteString span3ParentId = ByteString.copyFrom(buffer.array());
    // Span1 to verify span level tags precedence
    Model.Span span1 = Model.Span.newBuilder().setTraceId(traceId).setSpanId(span1Id).setDuration(Duration.newBuilder().setSeconds(1L).build()).setOperationName("HTTP GET").setStartTime(fromMillis(startTime)).addTags(componentTag).addTags(spanLevelAppTag).setFlags(1).build();
    Model.Span span2 = Model.Span.newBuilder().setTraceId(traceId).setSpanId(span2Id).setDuration(Duration.newBuilder().setSeconds(2L).build()).setOperationName("HTTP GET /").setStartTime(fromMillis(startTime)).addTags(componentTag).setFlags(1).addReferences(Model.SpanRef.newBuilder().setRefType(Model.SpanRefType.CHILD_OF).setSpanId(span1Id).setTraceId(traceId).build()).build();
    // check negative span IDs too
    Model.Span span3 = Model.Span.newBuilder().setTraceId(trace2Id).setSpanId(span3Id).setDuration(Duration.newBuilder().setSeconds(3L).build()).setOperationName("HTTP GET /").setStartTime(fromMillis(startTime)).setFlags(1).addReferences(Model.SpanRef.newBuilder().setRefType(Model.SpanRefType.CHILD_OF).setSpanId(span3ParentId).setTraceId(traceId).build()).build();
    Model.Batch testBatch = Model.Batch.newBuilder().setProcess(Model.Process.newBuilder().setServiceName("frontend").addTags(ipTag).addTags(processLevelAppTag).build()).addAllSpans(ImmutableList.of(span1, span2)).build();
    Collector.PostSpansRequest batches = Collector.PostSpansRequest.newBuilder().setBatch(testBatch).build();
    handler.postSpans(batches, emptyStreamObserver);
    Model.Batch testBatchForProxyLevel = Model.Batch.newBuilder().setProcess(Model.Process.newBuilder().setServiceName("frontend").addTags(ipTag).build()).addAllSpans(ImmutableList.of(span3)).build();
    Collector.PostSpansRequest batchesForProxyLevel = Collector.PostSpansRequest.newBuilder().setBatch(testBatchForProxyLevel).build();
    handler.postSpans(batchesForProxyLevel, emptyStreamObserver);
    verify(mockTraceHandler, mockTraceLogsHandler);
}
Also used : RateSampler(com.wavefront.sdk.entities.tracing.sampling.RateSampler) ByteString(com.google.protobuf.ByteString) SpanSampler(com.wavefront.agent.sampler.SpanSampler) Model(io.opentelemetry.exporters.jaeger.proto.api_v2.Model) Collector(io.opentelemetry.exporters.jaeger.proto.api_v2.Collector) ByteBuffer(java.nio.ByteBuffer) Annotation(wavefront.report.Annotation) Test(org.junit.Test)

Example 13 with SpanSampler

use of com.wavefront.agent.sampler.SpanSampler 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 14 with SpanSampler

use of com.wavefront.agent.sampler.SpanSampler in project java by wavefrontHQ.

the class JaegerTChannelCollectorHandlerTest method testSourceTagPriority.

@Test
public void testSourceTagPriority() 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("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();
    mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(4).setName("HTTP GET").setSource("source-processtag").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("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"))).build());
    expectLastCall();
    mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(3456).setName("HTTP GET /test").setSource("hostname-processtag").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();
    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 customSourceProcessTag = new Tag("source", TagType.STRING);
    customSourceProcessTag.setVStr("source-processtag");
    Tag customSourceSpanTag = new Tag("source", TagType.STRING);
    customSourceSpanTag.setVStr("source-spantag");
    io.jaegertracing.thriftjava.Span span1 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 2345678L, 1234567L, "HTTP GET /", 1, startTime * 1000, 9 * 1000);
    span1.setTags(ImmutableList.of(customSourceSpanTag));
    io.jaegertracing.thriftjava.Span span2 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 1234567L, 0L, "HTTP GET", 1, startTime * 1000, 4 * 1000);
    io.jaegertracing.thriftjava.Span span3 = new io.jaegertracing.thriftjava.Span(1231231232L, 1231232342340L, 349865507945L, 0, "HTTP GET /test", 1, startTime * 1000, 3456 * 1000);
    Batch testBatch = new Batch();
    testBatch.process = new Process();
    testBatch.process.serviceName = "frontend";
    testBatch.process.setTags(ImmutableList.of(ipTag, hostNameProcessTag, customSourceProcessTag));
    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);
    // Span3 to verify hostname process level tags precedence. So do not set any process level
    // source tag.
    Batch testBatchSourceAsProcessTagHostName = new Batch();
    testBatchSourceAsProcessTagHostName.process = new Process();
    testBatchSourceAsProcessTagHostName.process.serviceName = "frontend";
    testBatchSourceAsProcessTagHostName.process.setTags(ImmutableList.of(ipTag, hostNameProcessTag));
    testBatchSourceAsProcessTagHostName.setSpans(ImmutableList.of(span3));
    Collector.submitBatches_args batchesSourceAsProcessTagHostName = new Collector.submitBatches_args();
    batchesSourceAsProcessTagHostName.addToBatches(testBatchSourceAsProcessTagHostName);
    ThriftRequest<Collector.submitBatches_args> requestForProxyLevel = new ThriftRequest.Builder<Collector.submitBatches_args>("jaeger-collector", "Collector::submitBatches").setBody(batchesSourceAsProcessTagHostName).build();
    handler.handleImpl(requestForProxyLevel);
    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 15 with SpanSampler

use of com.wavefront.agent.sampler.SpanSampler 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

SpanSampler (com.wavefront.agent.sampler.SpanSampler)47 Test (org.junit.Test)42 RateSampler (com.wavefront.sdk.entities.tracing.sampling.RateSampler)38 Annotation (wavefront.report.Annotation)32 Span (wavefront.report.Span)18 EasyMock.anyString (org.easymock.EasyMock.anyString)14 Batch (io.jaegertracing.thriftjava.Batch)12 ByteString (com.google.protobuf.ByteString)11 Process (io.jaegertracing.thriftjava.Process)11 Tag (io.jaegertracing.thriftjava.Tag)11 Model (io.opentelemetry.exporters.jaeger.proto.api_v2.Model)11 ByteBuffer (java.nio.ByteBuffer)11 Collector (io.opentelemetry.exporters.jaeger.proto.api_v2.Collector)10 Socket (java.net.Socket)10 Collector (io.jaegertracing.thriftjava.Collector)9 BufferedOutputStream (java.io.BufferedOutputStream)9 HashMap (java.util.HashMap)9 ReportPoint (wavefront.report.ReportPoint)9 NoopHealthCheckManager (com.wavefront.agent.channel.NoopHealthCheckManager)7 ByteBuf (io.netty.buffer.ByteBuf)7