Search in sources :

Example 1 with LineBasedBlockFilter

use of com.wavefront.agent.preprocessor.LineBasedBlockFilter in project java by wavefrontHQ.

the class SpanUtilsTest method testSpanLogsLineDataBlockPreprocessor.

@Test
public void testSpanLogsLineDataBlockPreprocessor() {
    Supplier<ReportableEntityPreprocessor> preprocessorSupplier = () -> {
        ReportableEntityPreprocessor preprocessor = new ReportableEntityPreprocessor();
        PreprocessorRuleMetrics preprocessorRuleMetrics = new PreprocessorRuleMetrics(null, null, null);
        preprocessor.forPointLine().addFilter(new LineBasedBlockFilter(".*invalid.*", preprocessorRuleMetrics));
        return preprocessor;
    };
    String spanLine = "\"invalid.metric\" \"source\"=\"localdev\" " + "\"spanId\"=\"4217104a-690d-4927-baff-d9aa779414c2\" " + "\"traceId\"=\"d5355bf7-fc8d-48d1-b761-75b170f396e0\" " + "\"application\"=\"app\" \"service\"=\"svc\" " + startTime + " 100";
    String spanLogsLine = "{" + "\"customer\":\"dummy\"," + "\"traceId\":\"d5355bf7-fc8d-48d1-b761-75b170f396e0\"," + "\"spanId\":\"4217104a-690d-4927-baff-d9aa779414c2\"," + "\"logs\":[{\"timestamp\":" + startTime + ",\"fields\":{\"error" + ".kind\":\"exception\", \"event\":\"error\"}}]," + "\"span\":\"\\\"invalid.metric\\\" \\\"source\\\"=\\\"localdev\\\" " + "\\\"spanId\\\"=\\\"4217104a-690d-4927-baff-d9aa779414c2\\\" " + "\\\"traceId\\\"=\\\"d5355bf7-fc8d-48d1-b761-75b170f396e0\\\" " + "\\\"application\\\"=\\\"app\\\" \\\"service\\\"=\\\"svc\\\" " + startTime + " 100\"" + "}";
    SpanLogs spanLogs = SpanLogs.newBuilder().setSpan(spanLine).setTraceId("d5355bf7-fc8d-48d1-b761-75b170f396e0").setSpanId("4217104a-690d-4927-baff-d9aa779414c2").setCustomer("dummy").setLogs(ImmutableList.of(SpanLog.newBuilder().setFields(new HashMap<String, String>() {

        {
            put("error.kind", "exception");
            put("event", "error");
        }
    }).setTimestamp(startTime).build())).build();
    mockTraceSpanLogsHandler.block(spanLogs);
    expectLastCall();
    replay(mockTraceHandler, mockTraceSpanLogsHandler);
    handleSpanLogs(spanLogsLine, spanLogsDocoder, spanDecoder, mockTraceSpanLogsHandler, preprocessorSupplier, null, span -> true);
    verify(mockTraceSpanLogsHandler);
}
Also used : PreprocessorRuleMetrics(com.wavefront.agent.preprocessor.PreprocessorRuleMetrics) ReportableEntityPreprocessor(com.wavefront.agent.preprocessor.ReportableEntityPreprocessor) LineBasedBlockFilter(com.wavefront.agent.preprocessor.LineBasedBlockFilter) HashMap(java.util.HashMap) SpanLogs(wavefront.report.SpanLogs) SpanUtils.handleSpanLogs(com.wavefront.agent.listeners.tracing.SpanUtils.handleSpanLogs) Test(org.junit.Test)

Aggregations

SpanUtils.handleSpanLogs (com.wavefront.agent.listeners.tracing.SpanUtils.handleSpanLogs)1 LineBasedBlockFilter (com.wavefront.agent.preprocessor.LineBasedBlockFilter)1 PreprocessorRuleMetrics (com.wavefront.agent.preprocessor.PreprocessorRuleMetrics)1 ReportableEntityPreprocessor (com.wavefront.agent.preprocessor.ReportableEntityPreprocessor)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 SpanLogs (wavefront.report.SpanLogs)1