use of wavefront.report.Annotation in project java by wavefrontHQ.
the class PushAgentTest method testCustomTraceUnifiedPortHandlerDerivedMetrics.
@Test
public void testCustomTraceUnifiedPortHandlerDerivedMetrics() throws Exception {
customTracePort = findAvailablePort(51233);
proxy.proxyConfig.customTracingListenerPorts = String.valueOf(customTracePort);
setUserPreprocessorForTraceDerivedREDMetrics(customTracePort);
proxy.startCustomTracingListener(proxy.proxyConfig.getCustomTracingListenerPorts(), mockHandlerFactory, mockWavefrontSender, new SpanSampler(new RateSampler(1.0D), () -> null));
waitUntilListenerIsOnline(customTracePort);
reset(mockTraceHandler);
reset(mockWavefrontSender);
String traceId = UUID.randomUUID().toString();
String spanData = "testSpanName source=testsource spanId=testspanid " + "traceId=\"" + traceId + "\" " + startTime + " " + (startTime + 1) + "\n";
mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime * 1000).setDuration(1000).setName("testSpanName").setSource(PREPROCESSED_SOURCE_VALUE).setSpanId("testspanid").setTraceId(traceId).setAnnotations(ImmutableList.of(new Annotation("application", PREPROCESSED_APPLICATION_TAG_VALUE), new Annotation("service", PREPROCESSED_SERVICE_TAG_VALUE), new Annotation("cluster", PREPROCESSED_CLUSTER_TAG_VALUE), new Annotation("shard", PREPROCESSED_SHARD_TAG_VALUE))).build());
expectLastCall();
Capture<HashMap<String, String>> tagsCapture = EasyMock.newCapture();
mockWavefrontSender.sendMetric(eq(HEART_BEAT_METRIC), eq(1.0), anyLong(), eq(PREPROCESSED_SOURCE_VALUE), EasyMock.capture(tagsCapture));
expectLastCall().anyTimes();
replay(mockTraceHandler, mockWavefrontSender);
Socket socket = SocketFactory.getDefault().createSocket("localhost", customTracePort);
BufferedOutputStream stream = new BufferedOutputStream(socket.getOutputStream());
stream.write(spanData.getBytes());
stream.flush();
socket.close();
// sleep to get around "Nothing captured yet" issue with heartbeat metric call.
Thread.sleep(100);
verifyWithTimeout(500, mockTraceHandler, mockWavefrontSender);
HashMap<String, String> tagsReturned = tagsCapture.getValue();
assertEquals(PREPROCESSED_APPLICATION_TAG_VALUE, tagsReturned.get(APPLICATION_TAG_KEY));
assertEquals(PREPROCESSED_SERVICE_TAG_VALUE, tagsReturned.get(SERVICE_TAG_KEY));
assertEquals(PREPROCESSED_CLUSTER_TAG_VALUE, tagsReturned.get(CLUSTER_TAG_KEY));
assertEquals(PREPROCESSED_SHARD_TAG_VALUE, tagsReturned.get(SHARD_TAG_KEY));
}
use of wavefront.report.Annotation in project java by wavefrontHQ.
the class PushAgentTest method testRelayPortHandlerGzipped.
@Test
public void testRelayPortHandlerGzipped() throws Exception {
port = findAvailablePort(2888);
proxy.proxyConfig.pushRelayListenerPorts = String.valueOf(port);
proxy.proxyConfig.pushRelayHistogramAggregator = true;
proxy.proxyConfig.pushRelayHistogramAggregatorAccumulatorSize = 10L;
proxy.proxyConfig.pushRelayHistogramAggregatorFlushSecs = 1;
proxy.startRelayListener(proxy.proxyConfig.getPushRelayListenerPorts(), mockHandlerFactory, null);
waitUntilListenerIsOnline(port);
reset(mockPointHandler, mockHistogramHandler, mockTraceHandler, mockTraceSpanLogsHandler);
String traceId = UUID.randomUUID().toString();
long timestamp1 = startTime * 1000000 + 12345;
long timestamp2 = startTime * 1000000 + 23456;
String spanData = "testSpanName parent=parent1 source=testsource spanId=testspanid " + "traceId=\"" + traceId + "\" parent=parent2 " + startTime + " " + (startTime + 1);
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();
mockTraceSpanLogsHandler.report(SpanLogs.newBuilder().setCustomer("dummy").setTraceId(traceId).setSpanId("testspanid").setLogs(ImmutableList.of(SpanLog.newBuilder().setTimestamp(timestamp1).setFields(ImmutableMap.of("key", "value", "key2", "value2")).build(), SpanLog.newBuilder().setTimestamp(timestamp2).setFields(ImmutableMap.of("key3", "value3", "key4", "value4")).build())).build());
expectLastCall();
mockTraceSpanLogsHandler.report(SpanLogs.newBuilder().setCustomer("dummy").setTraceId(traceId).setSpanId("testspanid").setLogs(ImmutableList.of(SpanLog.newBuilder().setTimestamp(timestamp1).setFields(ImmutableMap.of("key", "value", "key2", "value2")).build(), SpanLog.newBuilder().setTimestamp(timestamp2).setFields(ImmutableMap.of("key3", "value3")).build())).setSpan(spanData).build());
expectLastCall();
mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime * 1000).setDuration(1000).setName("testSpanName").setSource("testsource").setSpanId("testspanid").setTraceId(traceId).setAnnotations(ImmutableList.of(new Annotation("parent", "parent1"), new Annotation("parent", "parent2"))).build());
expectLastCall();
mockPointHandler.reject(anyString(), anyString());
expectLastCall().times(2);
replay(mockPointHandler, mockHistogramHandler, mockTraceHandler, mockTraceSpanLogsHandler);
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";
String histoData = "!M " + startTime + " #5 10.0 #10 100.0 metric.test.histo source=test1\n" + "!M " + (startTime + 60) + " #5 20.0 #6 30.0 #7 40.0 metric.test.histo source=test2";
String spanLogData = "{\"spanId\":\"testspanid\",\"traceId\":\"" + traceId + "\",\"logs\":[{\"timestamp\":" + timestamp1 + ",\"fields\":{\"key\":\"value\",\"key2\":\"value2\"}},{\"timestamp\":" + timestamp2 + ",\"fields\":{\"key3\":\"value3\",\"key4\":\"value4\"}}]}\n";
String spanLogDataWithSpanField = "{\"spanId\":\"testspanid\",\"traceId\":\"" + traceId + "\",\"logs\":[{\"timestamp\":" + timestamp1 + ",\"fields\":{\"key\":\"value\",\"key2\":\"value2\"}},{\"timestamp\":" + timestamp2 + ",\"fields\":{\"key3\":\"value3\"}}]," + "\"span\":\"" + escapeSpanData(spanData) + "\"}\n";
String badData = "@SourceTag action=save source=testSource newtag1 newtag2\n" + "@Event " + startTime + " \"Event name for testing\" host=host1 host=host2 tag=tag1 " + "severity=INFO multi=bar multi=baz\n" + "!M " + (startTime + 60) + " #5 20.0 #6 30.0 #7 40.0 metric.test.histo source=test2";
assertEquals(200, gzippedHttpPost("http://localhost:" + port + "/api/v2/wfproxy/checkin", "{}"));
assertEquals(200, gzippedHttpPost("http://localhost:" + port + "/api/v2/wfproxy/report?format=wavefront", payloadStr));
assertEquals(200, gzippedHttpPost("http://localhost:" + port + "/api/v2/wfproxy/report?format=histogram", histoData));
assertEquals(200, gzippedHttpPost("http://localhost:" + port + "/api/v2/wfproxy/report?format=trace", spanData));
assertEquals(200, gzippedHttpPost("http://localhost:" + port + "/api/v2/wfproxy/report?format=spanLogs", spanLogData));
assertEquals(200, gzippedHttpPost("http://localhost:" + port + "/api/v2/wfproxy/report?format=spanLogs", spanLogDataWithSpanField));
proxy.entityProps.get(ReportableEntityType.HISTOGRAM).setFeatureDisabled(true);
assertEquals(403, gzippedHttpPost("http://localhost:" + port + "/api/v2/wfproxy/report?format=histogram", histoData));
proxy.entityProps.get(ReportableEntityType.TRACE).setFeatureDisabled(true);
assertEquals(403, gzippedHttpPost("http://localhost:" + port + "/api/v2/wfproxy/report?format=trace", spanData));
proxy.entityProps.get(ReportableEntityType.TRACE_SPAN_LOGS).setFeatureDisabled(true);
assertEquals(403, gzippedHttpPost("http://localhost:" + port + "/api/v2/wfproxy/report?format=spanLogs", spanLogData));
assertEquals(403, gzippedHttpPost("http://localhost:" + port + "/api/v2/wfproxy/report?format=spanLogs", spanLogDataWithSpanField));
assertEquals(400, gzippedHttpPost("http://localhost:" + port + "/api/v2/wfproxy/report?format=wavefront", badData));
verify(mockPointHandler, mockHistogramHandler, mockTraceHandler, mockTraceSpanLogsHandler);
}
use of wavefront.report.Annotation 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 wavefront.report.Annotation 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 wavefront.report.Annotation 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