Search in sources :

Example 31 with SpanSampler

use of com.wavefront.agent.sampler.SpanSampler in project java by wavefrontHQ.

the class PushAgentTest method testHistogramDataOnWavefrontUnifiedPortHandlerPlaintextUncompressed.

// test that histograms received on Wavefront port get routed to the correct handler
@Test
public void testHistogramDataOnWavefrontUnifiedPortHandlerPlaintextUncompressed() 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);
    mockHistogramHandler.report(ReportPoint.newBuilder().setTable("dummy").setMetric("metric.test.histo").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());
    mockHistogramHandler.report(ReportPoint.newBuilder().setTable("dummy").setMetric("metric.test.histo").setHost("test2").setTimestamp((startTime + 60) * 1000).setValue(Histogram.newBuilder().setType(HistogramType.TDIGEST).setDuration(60000).setBins(ImmutableList.of(20.0d, 30.0d, 40.0d)).setCounts(ImmutableList.of(5, 6, 7)).build()).build());
    expectLastCall();
    replay(mockHistogramHandler);
    Socket socket = SocketFactory.getDefault().createSocket("localhost", port);
    BufferedOutputStream stream = new BufferedOutputStream(socket.getOutputStream());
    String payloadStr = "!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\n";
    stream.write(payloadStr.getBytes());
    stream.flush();
    socket.close();
    verifyWithTimeout(500, mockHistogramHandler);
}
Also used : RateSampler(com.wavefront.sdk.entities.tracing.sampling.RateSampler) SpanSampler(com.wavefront.agent.sampler.SpanSampler) EasyMock.anyString(org.easymock.EasyMock.anyString) BufferedOutputStream(java.io.BufferedOutputStream) Socket(java.net.Socket) Test(org.junit.Test)

Example 32 with SpanSampler

use of com.wavefront.agent.sampler.SpanSampler in project java by wavefrontHQ.

the class PushAgentTest method testLargeHistogramDataOnWavefrontUnifiedPortHandler.

@Test
public void testLargeHistogramDataOnWavefrontUnifiedPortHandler() throws Exception {
    port = findAvailablePort(2988);
    proxy.proxyConfig.pushListenerPorts = String.valueOf(port);
    proxy.startGraphiteListener(proxy.proxyConfig.getPushListenerPorts(), mockHandlerFactory, null, new SpanSampler(new RateSampler(1.0D), () -> null));
    waitUntilListenerIsOnline(port);
    reset(mockHistogramHandler);
    List<Double> bins = new ArrayList<>();
    List<Integer> counts = new ArrayList<>();
    for (int i = 0; i < 50; i++) bins.add(10.0d);
    for (int i = 0; i < 150; i++) bins.add(99.0d);
    for (int i = 0; i < 200; i++) counts.add(1);
    mockHistogramHandler.report(ReportPoint.newBuilder().setTable("dummy").setMetric("metric.test.histo").setHost("test1").setTimestamp(startTime * 1000).setValue(Histogram.newBuilder().setType(HistogramType.TDIGEST).setDuration(60000).setBins(bins).setCounts(counts).build()).build());
    expectLastCall();
    replay(mockHistogramHandler);
    Socket socket = SocketFactory.getDefault().createSocket("localhost", port);
    BufferedOutputStream stream = new BufferedOutputStream(socket.getOutputStream());
    StringBuilder payloadStr = new StringBuilder("!M ");
    payloadStr.append(startTime);
    for (int i = 0; i < 50; i++) payloadStr.append(" #1 10.0");
    for (int i = 0; i < 150; i++) payloadStr.append(" #1 99.0");
    payloadStr.append(" metric.test.histo source=test1\n");
    stream.write(payloadStr.toString().getBytes());
    stream.flush();
    socket.close();
    verifyWithTimeout(500, mockHistogramHandler);
}
Also used : RateSampler(com.wavefront.sdk.entities.tracing.sampling.RateSampler) SpanSampler(com.wavefront.agent.sampler.SpanSampler) ArrayList(java.util.ArrayList) BufferedOutputStream(java.io.BufferedOutputStream) ReportPoint(wavefront.report.ReportPoint) Socket(java.net.Socket) Test(org.junit.Test)

Example 33 with SpanSampler

use of com.wavefront.agent.sampler.SpanSampler 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);
}
Also used : RateSampler(com.wavefront.sdk.entities.tracing.sampling.RateSampler) SpanSampler(com.wavefront.agent.sampler.SpanSampler) EasyMock.anyString(org.easymock.EasyMock.anyString) BufferedOutputStream(java.io.BufferedOutputStream) Socket(java.net.Socket) Test(org.junit.Test)

Example 34 with SpanSampler

use of com.wavefront.agent.sampler.SpanSampler 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"));
}
Also used : RateSampler(com.wavefront.sdk.entities.tracing.sampling.RateSampler) SpanSampler(com.wavefront.agent.sampler.SpanSampler) EasyMock.anyString(org.easymock.EasyMock.anyString) DeltaCounterAccumulationHandlerImpl(com.wavefront.agent.handlers.DeltaCounterAccumulationHandlerImpl) Test(org.junit.Test)

Example 35 with SpanSampler

use of com.wavefront.agent.sampler.SpanSampler 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);
}
Also used : RateSampler(com.wavefront.sdk.entities.tracing.sampling.RateSampler) ByteString(com.google.protobuf.ByteString) SpanSampler(com.wavefront.agent.sampler.SpanSampler) Model(io.opentelemetry.exporters.jaeger.proto.api_v2.Model) Collector(io.opentelemetry.exporters.jaeger.proto.api_v2.Collector) ByteBuffer(java.nio.ByteBuffer) Annotation(wavefront.report.Annotation) Test(org.junit.Test)

Aggregations

SpanSampler (com.wavefront.agent.sampler.SpanSampler)47 Test (org.junit.Test)42 RateSampler (com.wavefront.sdk.entities.tracing.sampling.RateSampler)38 Annotation (wavefront.report.Annotation)32 Span (wavefront.report.Span)18 EasyMock.anyString (org.easymock.EasyMock.anyString)14 Batch (io.jaegertracing.thriftjava.Batch)12 ByteString (com.google.protobuf.ByteString)11 Process (io.jaegertracing.thriftjava.Process)11 Tag (io.jaegertracing.thriftjava.Tag)11 Model (io.opentelemetry.exporters.jaeger.proto.api_v2.Model)11 ByteBuffer (java.nio.ByteBuffer)11 Collector (io.opentelemetry.exporters.jaeger.proto.api_v2.Collector)10 Socket (java.net.Socket)10 Collector (io.jaegertracing.thriftjava.Collector)9 BufferedOutputStream (java.io.BufferedOutputStream)9 HashMap (java.util.HashMap)9 ReportPoint (wavefront.report.ReportPoint)9 NoopHealthCheckManager (com.wavefront.agent.channel.NoopHealthCheckManager)7 ByteBuf (io.netty.buffer.ByteBuf)7