use of com.wavefront.agent.sampler.SpanSampler in project java by wavefrontHQ.
the class JaegerGrpcCollectorHandlerTest method testSourceTagPriority.
@Test
public void testSourceTagPriority() throws Exception {
reset(mockTraceHandler, mockTraceLogsHandler);
mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(9000).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("service", "frontend"), new Annotation("application", "Jaeger"), 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(4000).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("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(3000).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("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 hostNameProcessTag = Model.KeyValue.newBuilder().setKey("hostname").setVStr("hostname-processtag").setVType(Model.ValueType.STRING).build();
Model.KeyValue customSourceProcessTag = Model.KeyValue.newBuilder().setKey("source").setVStr("source-processtag").setVType(Model.ValueType.STRING).build();
Model.KeyValue customSourceSpanTag = Model.KeyValue.newBuilder().setKey("source").setVStr("source-spantag").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(1231232342340L);
buffer.putLong(1231231232L);
ByteString trace2Id = ByteString.copyFrom(buffer.array());
buffer = ByteBuffer.allocate(Long.BYTES);
buffer.putLong(2345678L);
ByteString span1Id = ByteString.copyFrom(buffer.array());
buffer = ByteBuffer.allocate(Long.BYTES);
buffer.putLong(1234567L);
ByteString span2Id = ByteString.copyFrom(buffer.array());
buffer = ByteBuffer.allocate(Long.BYTES);
buffer.putLong(349865507945L);
ByteString span3Id = ByteString.copyFrom(buffer.array());
Model.Span span1 = Model.Span.newBuilder().setTraceId(traceId).setSpanId(span1Id).setDuration(Duration.newBuilder().setSeconds(9L).build()).setOperationName("HTTP GET /").addTags(customSourceSpanTag).addReferences(Model.SpanRef.newBuilder().setRefType(Model.SpanRefType.CHILD_OF).setSpanId(span2Id).setTraceId(traceId).build()).setStartTime(fromMillis(startTime)).build();
Model.Span span2 = Model.Span.newBuilder().setTraceId(traceId).setSpanId(span2Id).setDuration(Duration.newBuilder().setSeconds(4L).build()).setOperationName("HTTP GET").setStartTime(fromMillis(startTime)).build();
Model.Span span3 = Model.Span.newBuilder().setTraceId(trace2Id).setSpanId(span3Id).setDuration(Duration.newBuilder().setSeconds(3L).build()).setOperationName("HTTP GET /test").setStartTime(fromMillis(startTime)).build();
Model.Batch testBatch = Model.Batch.newBuilder().setProcess(Model.Process.newBuilder().setServiceName("frontend").addTags(ipTag).addTags(hostNameProcessTag).addTags(customSourceProcessTag).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).addTags(hostNameProcessTag).build()).addAllSpans(ImmutableList.of(span3)).build();
Collector.PostSpansRequest batchesSourceAsProcessTagHostName = Collector.PostSpansRequest.newBuilder().setBatch(testBatchForProxyLevel).build();
handler.postSpans(batchesSourceAsProcessTagHostName, emptyStreamObserver);
verify(mockTraceHandler, mockTraceLogsHandler);
}
use of com.wavefront.agent.sampler.SpanSampler in project java by wavefrontHQ.
the class JaegerGrpcCollectorHandlerTest method testAllProcessTagsPropagated.
@Test
public void testAllProcessTagsPropagated() throws Exception {
reset(mockTraceHandler, mockTraceLogsHandler);
mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(9000).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("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 hostNameProcessTag = Model.KeyValue.newBuilder().setKey("hostname").setVStr("hostname-processtag").setVType(Model.ValueType.STRING).build();
Model.KeyValue customProcessTag1 = Model.KeyValue.newBuilder().setKey("processTag1").setVStr("one").setVType(Model.ValueType.STRING).build();
Model.KeyValue customProcessTag2 = Model.KeyValue.newBuilder().setKey("processTag2").setVStr("two").setVType(Model.ValueType.STRING).build();
Model.KeyValue customProcessTag3 = Model.KeyValue.newBuilder().setKey("processTag3").setVStr("three").setVType(Model.ValueType.STRING).build();
Model.KeyValue customSourceSpanTag = Model.KeyValue.newBuilder().setKey("source").setVStr("source-spantag").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);
buffer.putLong(2345678L);
ByteString spanId = ByteString.copyFrom(buffer.array());
Model.Span span = Model.Span.newBuilder().setTraceId(traceId).setSpanId(spanId).setDuration(Duration.newBuilder().setSeconds(9L).build()).setOperationName("HTTP GET /").addTags(customSourceSpanTag).setStartTime(fromMillis(startTime)).build();
Model.Batch testBatch = Model.Batch.newBuilder().setProcess(Model.Process.newBuilder().setServiceName("frontend").addTags(ipTag).addTags(hostNameProcessTag).addTags(customProcessTag1).addTags(customProcessTag2).addTags(customProcessTag3).build()).addAllSpans(ImmutableList.of(span)).build();
Collector.PostSpansRequest batches = Collector.PostSpansRequest.newBuilder().setBatch(testBatch).build();
handler.postSpans(batches, emptyStreamObserver);
verify(mockTraceHandler, mockTraceLogsHandler);
}
use of com.wavefront.agent.sampler.SpanSampler in project java by wavefrontHQ.
the class JaegerGrpcCollectorHandlerTest method testJaegerDebugOverride.
@Test
public void testJaegerDebugOverride() throws Exception {
reset(mockTraceHandler, mockTraceLogsHandler);
mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(9000).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("debug", "true"), new Annotation("application", "Jaeger"), 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(4000).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("sampling.priority", "0.3"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("_sampledByPolicy", "test"))).build());
expectLastCall();
replay(mockTraceHandler, mockTraceLogsHandler);
JaegerGrpcCollectorHandler handler = new JaegerGrpcCollectorHandler("9876", mockTraceHandler, mockTraceLogsHandler, null, () -> false, () -> false, null, new SpanSampler(new DurationSampler(10 * 1000), () -> ImmutableList.of(new SpanSamplingPolicy("test", "{{sampling.priority}}='0.3'", 100))), null, null);
Model.KeyValue ipTag = Model.KeyValue.newBuilder().setKey("ip").setVStr("10.0.0.1").setVType(Model.ValueType.STRING).build();
Model.KeyValue debugTag = Model.KeyValue.newBuilder().setKey("debug").setVStr("true").setVType(Model.ValueType.STRING).build();
Model.KeyValue samplePriorityTag = Model.KeyValue.newBuilder().setKey("sampling.priority").setVFloat64(0.3).setVType(Model.ValueType.FLOAT64).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);
buffer.putLong(2345678L);
ByteString span1Id = ByteString.copyFrom(buffer.array());
buffer = ByteBuffer.allocate(Long.BYTES);
buffer.putLong(1234567L);
ByteString span2Id = ByteString.copyFrom(buffer.array());
Model.Span span1 = Model.Span.newBuilder().setTraceId(traceId).setSpanId(span1Id).setDuration(Duration.newBuilder().setSeconds(9L).build()).setOperationName("HTTP GET /").addTags(debugTag).addReferences(Model.SpanRef.newBuilder().setRefType(Model.SpanRefType.CHILD_OF).setSpanId(span2Id).setTraceId(traceId).build()).setStartTime(fromMillis(startTime)).build();
Model.Span span2 = Model.Span.newBuilder().setTraceId(traceId).setSpanId(span2Id).setDuration(Duration.newBuilder().setSeconds(4L).build()).setOperationName("HTTP GET").addTags(samplePriorityTag).setStartTime(fromMillis(startTime)).build();
Model.Batch testBatch = Model.Batch.newBuilder().setProcess(Model.Process.newBuilder().setServiceName("frontend").addTags(ipTag).build()).addAllSpans(ImmutableList.of(span1, span2)).build();
Collector.PostSpansRequest batches = Collector.PostSpansRequest.newBuilder().setBatch(testBatch).build();
handler.postSpans(batches, emptyStreamObserver);
verify(mockTraceHandler, mockTraceLogsHandler);
}
use of com.wavefront.agent.sampler.SpanSampler in project java by wavefrontHQ.
the class JaegerGrpcCollectorHandlerTest 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(9000).setName("HTTP GET /").setSource("source-spantag").setSpanId("00000000-0000-0000-0000-00000023cace").setTraceId("00000000-4996-02d2-0000-011f71fb04cb").setAnnotations(ImmutableList.of(new Annotation("service", "frontend"), new Annotation("application", "application-processtag"), new Annotation("cluster", "cluster-processtag"), new Annotation("shard", "shard-processtag"))).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 customSourceSpanTag = Model.KeyValue.newBuilder().setKey("source").setVStr("source-spantag").setVType(Model.ValueType.STRING).build();
Model.KeyValue customApplicationProcessTag = Model.KeyValue.newBuilder().setKey("application").setVStr("application-processtag").setVType(Model.ValueType.STRING).build();
Model.KeyValue customClusterProcessTag = Model.KeyValue.newBuilder().setKey("cluster").setVStr("cluster-processtag").setVType(Model.ValueType.STRING).build();
Model.KeyValue customShardProcessTag = Model.KeyValue.newBuilder().setKey("shard").setVStr("shard-processtag").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);
buffer.putLong(2345678L);
ByteString spanId = ByteString.copyFrom(buffer.array());
Model.Span span = Model.Span.newBuilder().setTraceId(traceId).setSpanId(spanId).setDuration(Duration.newBuilder().setSeconds(9L).build()).setOperationName("HTTP GET /").addTags(customSourceSpanTag).setStartTime(fromMillis(startTime)).build();
Model.Batch testBatch = Model.Batch.newBuilder().setProcess(Model.Process.newBuilder().setServiceName("frontend").addTags(customApplicationProcessTag).addTags(customClusterProcessTag).addTags(customShardProcessTag).build()).addAllSpans(ImmutableList.of(span)).build();
Collector.PostSpansRequest batches = Collector.PostSpansRequest.newBuilder().setBatch(testBatch).build();
handler.postSpans(batches, emptyStreamObserver);
verify(mockTraceHandler, mockTraceLogsHandler);
}
use of com.wavefront.agent.sampler.SpanSampler in project java by wavefrontHQ.
the class JaegerTChannelCollectorHandlerTest method testJaegerDebugOverride.
@Test
public void testJaegerDebugOverride() throws Exception {
reset(mockTraceHandler, mockTraceLogsHandler);
Span expectedSpan1 = 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("debug", "true"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("_spanLogs", "true"))).build();
mockTraceHandler.report(expectedSpan1);
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();
Span expectedSpan2 = Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(4).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("sampling.priority", "0.3"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("_spanLogs", "true"), new Annotation("_sampledByPolicy", "test"))).build();
mockTraceHandler.report(expectedSpan2);
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();
replay(mockTraceHandler, mockTraceLogsHandler);
JaegerTChannelCollectorHandler handler = new JaegerTChannelCollectorHandler("9876", mockTraceHandler, mockTraceLogsHandler, null, () -> false, () -> false, null, new SpanSampler(new DurationSampler(10), () -> ImmutableList.of(new SpanSamplingPolicy("test", "{{sampling.priority}}='0.3'", 100))), null, null);
Tag ipTag = new Tag("ip", TagType.STRING);
ipTag.setVStr("10.0.0.1");
Tag debugTag = new Tag("debug", TagType.STRING);
debugTag.setVStr("true");
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(debugTag));
Tag samplePriorityTag = new Tag("sampling.priority", TagType.DOUBLE);
samplePriorityTag.setVDouble(0.3);
io.jaegertracing.thriftjava.Span span2 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 1234567L, 0L, "HTTP GET", 1, startTime * 1000, 4 * 1000);
span2.setTags(ImmutableList.of(samplePriorityTag));
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);
}
Aggregations