use of wavefront.report.Annotation 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);
}
use of wavefront.report.Annotation in project java by wavefrontHQ.
the class SpanUtilsTest method testSpanTagBlockPreprocessor.
@Test
public void testSpanTagBlockPreprocessor() {
Supplier<ReportableEntityPreprocessor> preprocessorSupplier = () -> {
ReportableEntityPreprocessor preprocessor = new ReportableEntityPreprocessor();
PreprocessorRuleMetrics preprocessorRuleMetrics = new PreprocessorRuleMetrics(null, null, null);
preprocessor.forSpan().addFilter(new SpanBlockFilter(SERVICE_TAG_KEY, "^test.*", null, preprocessorRuleMetrics));
return preprocessor;
};
String spanLine = "\"valid.metric\" \"source\"=\"localdev\" " + "\"spanId\"=\"4217104a-690d-4927-baff-d9aa779414c2\" " + "\"traceId\"=\"d5355bf7-fc8d-48d1-b761-75b170f396e0\" " + "\"application\"=\"app\" \"service\"=\"test\" " + startTime + " 100";
mockTraceHandler.block(new Span("valid.metric", "4217104a-690d-4927-baff" + "-d9aa779414c2", "d5355bf7-fc8d-48d1-b761-75b170f396e0", startTime, 100L, "localdev", "dummy", ImmutableList.of(new Annotation("application", "app"), new Annotation("service", "test"))));
expectLastCall();
replay(mockTraceHandler, mockTraceSpanLogsHandler);
preprocessAndHandleSpan(spanLine, spanDecoder, mockTraceHandler, mockTraceHandler::report, preprocessorSupplier, null, span -> true);
verify(mockTraceHandler);
}
Aggregations