use of com.wavefront.sdk.entities.tracing.sampling.RateSampler 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.sdk.entities.tracing.sampling.RateSampler in project java by wavefrontHQ.
the class JaegerTChannelCollectorHandlerTest method testIgnoresServiceTags.
@Test
public void testIgnoresServiceTags() throws Exception {
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", "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("source-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 sourceProcessTag = new Tag("source", TagType.STRING);
sourceProcessTag.setVStr("source-processtag");
Tag customServiceProcessTag = new Tag("service", TagType.STRING);
customServiceProcessTag.setVStr("service-processtag");
Tag customServiceSpanTag = new Tag("service", TagType.STRING);
customServiceSpanTag.setVStr("service-spantag");
io.jaegertracing.thriftjava.Span span1 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 2345678L, 0, "HTTP GET /", 1, startTime * 1000, 9 * 1000);
span1.setTags(ImmutableList.of(customServiceSpanTag));
io.jaegertracing.thriftjava.Span span2 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 1234567L, 0, "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, sourceProcessTag, customServiceProcessTag));
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);
Batch testBatchWithoutProcessTag = new Batch();
testBatchWithoutProcessTag.process = new Process();
testBatchWithoutProcessTag.process.serviceName = "frontend";
testBatchWithoutProcessTag.process.setTags(ImmutableList.of(ipTag, sourceProcessTag));
testBatchWithoutProcessTag.setSpans(ImmutableList.of(span3));
Collector.submitBatches_args batchesWithoutProcessTags = new Collector.submitBatches_args();
batchesWithoutProcessTags.addToBatches(testBatchWithoutProcessTag);
ThriftRequest<Collector.submitBatches_args> requestForProxyLevel = new ThriftRequest.Builder<Collector.submitBatches_args>("jaeger-collector", "Collector::submitBatches").setBody(batchesWithoutProcessTags).build();
handler.handleImpl(requestForProxyLevel);
verify(mockTraceHandler, mockTraceLogsHandler);
}
use of com.wavefront.sdk.entities.tracing.sampling.RateSampler in project java by wavefrontHQ.
the class JaegerTChannelCollectorHandlerTest method testJaegerTChannelCollector.
@Test
public void testJaegerTChannelCollector() throws Exception {
reset(mockTraceHandler, mockTraceLogsHandler);
Span expectedSpan1 = Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(1234).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("component", "db"), 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-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(2345).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("component", "db"), new Annotation("application", "Custom-JaegerApp"), new Annotation("cluster", "none"), new Annotation("shard", "none"))).build());
expectLastCall();
mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(3456).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("jaegerSpanId", "9a12b85901d53397"), new Annotation("jaegerTraceId", "fea487ee36e58cab"), new Annotation("service", "frontend"), new Annotation("parent", "00000000-0000-0000-fea4-87ee36e58cab"), new Annotation("application", "Jaeger"), new Annotation("cluster", "none"), new Annotation("shard", "none"))).build());
expectLastCall();
// Test filtering empty tags
mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(3456).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("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 componentTag = new Tag("component", TagType.STRING);
componentTag.setVStr("db");
Tag customApplicationTag = new Tag("application", TagType.STRING);
customApplicationTag.setVStr("Custom-JaegerApp");
Tag emptyTag = new Tag("empty", TagType.STRING);
emptyTag.setVStr("");
io.jaegertracing.thriftjava.Span span1 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 1234567L, 0L, "HTTP GET", 1, startTime * 1000, 1234 * 1000);
io.jaegertracing.thriftjava.Span span2 = new io.jaegertracing.thriftjava.Span(1234567890123L, 1234567890L, 2345678L, 1234567L, "HTTP GET /", 1, startTime * 1000, 2345 * 1000);
// check negative span IDs too
io.jaegertracing.thriftjava.Span span3 = new io.jaegertracing.thriftjava.Span(-97803834702328661L, 0L, -7344605349865507945L, -97803834702328661L, "HTTP GET /", 1, startTime * 1000, 3456 * 1000);
io.jaegertracing.thriftjava.Span span4 = new io.jaegertracing.thriftjava.Span(1231231232L, 1231232342340L, 349865507945L, 0, "HTTP GET /test", 1, startTime * 1000, 3456 * 1000);
span1.setTags(ImmutableList.of(componentTag));
span2.setTags(ImmutableList.of(componentTag, customApplicationTag));
span4.setTags(ImmutableList.of(emptyTag));
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))));
Batch testBatch = new Batch();
testBatch.process = new Process();
testBatch.process.serviceName = "frontend";
testBatch.process.setTags(ImmutableList.of(ipTag));
testBatch.setSpans(ImmutableList.of(span1, span2, span3, span4));
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 com.wavefront.sdk.entities.tracing.sampling.RateSampler in project java by wavefrontHQ.
the class PushAgentTest method testWavefrontUnifiedPortHandlerHttpGzipped.
@Test
public void testWavefrontUnifiedPortHandlerHttpGzipped() throws Exception {
port = findAvailablePort(2888);
int securePort = findAvailablePort(2889);
proxy.proxyConfig.privateCertPath = getClass().getClassLoader().getResource("demo.cert").getPath();
proxy.proxyConfig.privateKeyPath = getClass().getClassLoader().getResource("demo.key").getPath();
proxy.proxyConfig.tlsPorts = "1,23 , 4, , " + securePort + " ,6";
proxy.initSslContext();
proxy.proxyConfig.pushListenerPorts = port + "," + securePort;
SpanSampler sampler = new SpanSampler(new RateSampler(1.0D), () -> null);
proxy.startGraphiteListener(String.valueOf(port), mockHandlerFactory, null, sampler);
proxy.startGraphiteListener(String.valueOf(securePort), mockHandlerFactory, null, sampler);
waitUntilListenerIsOnline(port);
waitUntilListenerIsOnline(securePort);
reset(mockPointHandler);
mockPointHandler.report(ReportPoint.newBuilder().setTable("dummy").setMetric("metric4.test").setHost("test1").setTimestamp(startTime * 1000).setValue(0.0d).build());
expectLastCall();
mockPointHandler.report(ReportPoint.newBuilder().setTable("dummy").setMetric("metric4.test").setHost("test2").setTimestamp((startTime + 1) * 1000).setValue(1.0d).build());
expectLastCall();
mockPointHandler.report(ReportPoint.newBuilder().setTable("dummy").setMetric("metric4.test").setHost("test3").setTimestamp((startTime + 2) * 1000).setValue(2.0d).build());
expectLastCall();
replay(mockPointHandler);
// try http connection with gzip
String payloadStr = "metric4.test 0 " + startTime + " source=test1\n" + "metric4.test 1 " + (startTime + 1) + " source=test2\n" + "metric4.test 2 " + (startTime + 2) + // note the lack of newline at the end!
" source=test3";
gzippedHttpPost("http://localhost:" + port, payloadStr);
verify(mockPointHandler);
reset(mockPointHandler);
mockPointHandler.report(ReportPoint.newBuilder().setTable("dummy").setMetric("metric_4.test").setHost("test1").setTimestamp(startTime * 1000).setValue(0.0d).build());
expectLastCall();
mockPointHandler.report(ReportPoint.newBuilder().setTable("dummy").setMetric("metric_4.test").setHost("test2").setTimestamp((startTime + 1) * 1000).setValue(1.0d).build());
expectLastCall();
mockPointHandler.report(ReportPoint.newBuilder().setTable("dummy").setMetric("metric_4.test").setHost("test3").setTimestamp((startTime + 2) * 1000).setValue(2.0d).build());
expectLastCall();
replay(mockPointHandler);
// try secure http connection with gzip
payloadStr = "metric_4.test 0 " + startTime + " source=test1\n" + "metric_4.test 1 " + (startTime + 1) + " source=test2\n" + "metric_4.test 2 " + (startTime + 2) + // note the lack of newline at the end!
" source=test3";
gzippedHttpPost("https://localhost:" + securePort, payloadStr);
verify(mockPointHandler);
}
use of com.wavefront.sdk.entities.tracing.sampling.RateSampler in project java by wavefrontHQ.
the class PushAgentTest method testWavefrontUnifiedPortHandlerPlaintextUncompressed.
@Test
public void testWavefrontUnifiedPortHandlerPlaintextUncompressed() throws Exception {
port = findAvailablePort(2888);
int securePort = findAvailablePort(2889);
proxy.proxyConfig.privateCertPath = getClass().getClassLoader().getResource("demo.cert").getPath();
proxy.proxyConfig.privateKeyPath = getClass().getClassLoader().getResource("demo.key").getPath();
proxy.proxyConfig.tlsPorts = "1,23 , 4, , " + securePort + " ,6";
proxy.initSslContext();
proxy.proxyConfig.pushListenerPorts = port + "," + securePort;
SpanSampler sampler = new SpanSampler(new RateSampler(1.0D), () -> null);
proxy.startGraphiteListener(String.valueOf(port), mockHandlerFactory, null, sampler);
proxy.startGraphiteListener(String.valueOf(securePort), mockHandlerFactory, null, sampler);
waitUntilListenerIsOnline(port);
waitUntilListenerIsOnline(securePort);
reset(mockPointHandler);
mockPointHandler.report(ReportPoint.newBuilder().setTable("dummy").setMetric("metric.test").setHost("test1").setTimestamp(startTime * 1000).setValue(0.0d).build());
expectLastCall();
mockPointHandler.report(ReportPoint.newBuilder().setTable("dummy").setMetric("metric.test").setHost("test2").setTimestamp((startTime + 1) * 1000).setValue(1.0d).build());
expectLastCall();
replay(mockPointHandler);
// try plaintext over tcp first
Socket socket = SocketFactory.getDefault().createSocket("localhost", port);
BufferedOutputStream stream = new BufferedOutputStream(socket.getOutputStream());
String payloadStr = "metric.test 0 " + startTime + " source=test1\n" + "metric.test 1 " + (startTime + 1) + " source=test2\n";
stream.write(payloadStr.getBytes());
stream.flush();
socket.close();
verifyWithTimeout(500, mockPointHandler);
reset(mockPointHandler);
mockPointHandler.report(ReportPoint.newBuilder().setTable("dummy").setMetric("metric.test").setHost("test3").setTimestamp(startTime * 1000).setValue(0.0d).build());
expectLastCall();
mockPointHandler.report(ReportPoint.newBuilder().setTable("dummy").setMetric("metric.test").setHost("test4").setTimestamp((startTime + 1) * 1000).setValue(1.0d).build());
expectLastCall();
replay(mockPointHandler);
// secure test
socket = sslSocketFactory.createSocket("localhost", securePort);
stream = new BufferedOutputStream(socket.getOutputStream());
payloadStr = "metric.test 0 " + startTime + " source=test3\n" + "metric.test 1 " + (startTime + 1) + " source=test4\n";
stream.write(payloadStr.getBytes());
stream.flush();
socket.close();
verifyWithTimeout(500, mockPointHandler);
}
Aggregations