use of com.wavefront.sdk.entities.tracing.sampling.RateSampler in project java by wavefrontHQ.
the class PushAgentTest method testWavefrontUnifiedPortHandlerPlaintextUncompressedMixedDataPayload.
// test Wavefront port handler with mixed payload: metrics, histograms, source tags
@Test
public void testWavefrontUnifiedPortHandlerPlaintextUncompressedMixedDataPayload() throws Exception {
port = findAvailablePort(2888);
proxy.proxyConfig.pushListenerPorts = String.valueOf(port);
proxy.startGraphiteListener(proxy.proxyConfig.getPushListenerPorts(), mockHandlerFactory, null, new SpanSampler(new RateSampler(1.0D), () -> null));
waitUntilListenerIsOnline(port);
reset(mockHistogramHandler);
reset(mockPointHandler);
reset(mockSourceTagHandler);
reset(mockEventHandler);
mockPointHandler.report(ReportPoint.newBuilder().setTable("dummy").setMetric("metric.test.mixed").setHost("test2").setTimestamp((startTime + 1) * 1000).setValue(10d).build());
mockHistogramHandler.report(ReportPoint.newBuilder().setTable("dummy").setMetric("metric.test.mixed").setHost("test1").setTimestamp(startTime * 1000).setValue(Histogram.newBuilder().setType(HistogramType.TDIGEST).setDuration(60000).setBins(ImmutableList.of(10.0d, 100.0d)).setCounts(ImmutableList.of(5, 10)).build()).build());
mockEventHandler.report(ReportEvent.newBuilder().setStartTime(startTime * 1000).setEndTime(startTime * 1000 + 1).setName("Event name for testing").setHosts(ImmutableList.of("host1", "host2")).setDimensions(ImmutableMap.of("multi", ImmutableList.of("bar", "baz"))).setAnnotations(ImmutableMap.of("severity", "INFO")).setTags(ImmutableList.of("tag1")).build());
mockPointHandler.report(ReportPoint.newBuilder().setTable("dummy").setMetric("metric.test.mixed").setHost("test2").setTimestamp((startTime + 1) * 1000).setValue(9d).build());
mockSourceTagHandler.report(ReportSourceTag.newBuilder().setOperation(SourceOperationType.SOURCE_TAG).setAction(SourceTagAction.SAVE).setSource("testSource").setAnnotations(ImmutableList.of("newtag1", "newtag2")).build());
expectLastCall();
replay(mockPointHandler);
replay(mockHistogramHandler);
replay(mockEventHandler);
Socket socket = SocketFactory.getDefault().createSocket("localhost", port);
BufferedOutputStream stream = new BufferedOutputStream(socket.getOutputStream());
String payloadStr = "metric.test.mixed 10.0 " + (startTime + 1) + " source=test2\n" + "!M " + startTime + " #5 10.0 #10 100.0 metric.test.mixed source=test1\n" + "@SourceTag action=save source=testSource newtag1 newtag2\n" + "metric.test.mixed 9.0 " + (startTime + 1) + " source=test2\n" + "@Event " + startTime + " \"Event name for testing\" host=host1 host=host2 tag=tag1 " + "severity=INFO multi=bar multi=baz\n";
stream.write(payloadStr.getBytes());
stream.flush();
socket.close();
verifyWithTimeout(500, mockPointHandler, mockHistogramHandler, mockEventHandler);
}
use of com.wavefront.sdk.entities.tracing.sampling.RateSampler in project java by wavefrontHQ.
the class PushAgentTest method testDeltaCounterHandlerDataStream.
@Test
public void testDeltaCounterHandlerDataStream() throws Exception {
deltaPort = findAvailablePort(5888);
proxy.proxyConfig.deltaCountersAggregationListenerPorts = String.valueOf(deltaPort);
proxy.proxyConfig.deltaCountersAggregationIntervalSeconds = 10;
proxy.startDeltaCounterListener(proxy.proxyConfig.getDeltaCountersAggregationListenerPorts(), null, mockSenderTaskFactory, new SpanSampler(new RateSampler(1.0D), () -> null));
waitUntilListenerIsOnline(deltaPort);
reset(mockSenderTask);
Capture<String> capturedArgument = Capture.newInstance(CaptureType.ALL);
mockSenderTask.add(EasyMock.capture(capturedArgument));
expectLastCall().atLeastOnce();
replay(mockSenderTask);
String payloadStr = "∆test.mixed 1.0 " + startTime + " source=test1\n";
assertEquals(202, httpPost("http://localhost:" + deltaPort, payloadStr + payloadStr));
ReportableEntityHandler<?, ?> handler = proxy.deltaCounterHandlerFactory.getHandler(HandlerKey.of(ReportableEntityType.POINT, String.valueOf(deltaPort)));
if (!(handler instanceof DeltaCounterAccumulationHandlerImpl))
fail();
((DeltaCounterAccumulationHandlerImpl) handler).flushDeltaCounters();
assertEquals(202, httpPost("http://localhost:" + deltaPort, payloadStr));
assertEquals(202, httpPost("http://localhost:" + deltaPort, payloadStr + payloadStr));
((DeltaCounterAccumulationHandlerImpl) handler).flushDeltaCounters();
verify(mockSenderTask);
assertEquals(2, capturedArgument.getValues().size());
assertTrue(capturedArgument.getValues().get(0).startsWith("\"∆test.mixed\" 2.0"));
assertTrue(capturedArgument.getValues().get(1).startsWith("\"∆test.mixed\" 3.0"));
}
use of com.wavefront.sdk.entities.tracing.sampling.RateSampler in project java by wavefrontHQ.
the class JaegerGrpcCollectorHandlerTest method testProtectedTagsSpanOverridesProcess.
@Test
public void testProtectedTagsSpanOverridesProcess() 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-spantag"), new Annotation("cluster", "cluster-spantag"), new Annotation("shard", "shard-spantag"))).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 customApplicationSpanTag = Model.KeyValue.newBuilder().setKey("application").setVStr("application-spantag").setVType(Model.ValueType.STRING).build();
Model.KeyValue customClusterProcessTag = Model.KeyValue.newBuilder().setKey("cluster").setVStr("cluster-processtag").setVType(Model.ValueType.STRING).build();
Model.KeyValue customClusterSpanTag = Model.KeyValue.newBuilder().setKey("cluster").setVStr("cluster-spantag").setVType(Model.ValueType.STRING).build();
Model.KeyValue customShardProcessTag = Model.KeyValue.newBuilder().setKey("shard").setVStr("shard-processtag").setVType(Model.ValueType.STRING).build();
Model.KeyValue customShardSpanTag = Model.KeyValue.newBuilder().setKey("shard").setVStr("shard-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).addTags(customApplicationSpanTag).addTags(customClusterSpanTag).addTags(customShardSpanTag).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 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.sdk.entities.tracing.sampling.RateSampler 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);
}
Aggregations