ElasticsearchSpanReporter extends SpanReporter { @Override public boolean isActive(SpanContextInformation spanContext) { final boolean logOnly = elasticsearchTracingPlugin.isOnlyLogElasticsearchSpanReports(); return elasticsearchClient.isElasticsearchAvailable() || logOnly; } ElasticsearchSpanReporter();   ElasticsearchSpanReporter(Logger spanLogger); @Override void init(ConfigurationRegistry configuration); @Override void report(SpanContextInformation spanContext, final SpanWrapper spanWrapper); @Override boolean isActive(SpanContextInformation spanContext); @Override void updateSpan(B3HeaderFormat.B3Identifiers spanIdentifiers, B3HeaderFormat.B3Identifiers newSpanIdentifiers, Map<String, Object> tagsToUpdate);  }
@Test public void testReportSpan() throws Exception { final SpanContextInformation spanContext = reportSpanWithCallTree(1000, "Report Me"); final List<MockSpan> sampledSpans = getSampledSpans(); assertThat(sampledSpans).hasSize(1); Mockito.verify(httpClient).send(any(), any(), any(), any(), any()); Assert.assertTrue(reporter.isActive(spanContext)); }
@Test public void testLogReportSpan() throws Exception { Mockito.when(elasticsearchTracingPlugin.isOnlyLogElasticsearchSpanReports()).thenReturn(true); final SpanContextInformation spanContext = reportSpanWithCallTree(1000, "Report Me"); final List<MockSpan> sampledSpans = getSampledSpans(); assertThat(sampledSpans).hasSize(1); Mockito.verify(httpClient, Mockito.times(0)).send(any(), any(), any(), any(), any()); Mockito.verify(spanLogger).info(ArgumentMatchers.startsWith("{\"index\":{\"_index\":\"stagemonitor-spans-" + StringUtils.getLogstashStyleDate() + "\",\"_type\":\"spans\"}}\n")); Assert.assertTrue(reporter.isActive(spanContext)); }
@Test public void testReportSpanDontReport() throws Exception { final SpanContextInformation info = reportSpanWithCallTree(1, "Regular Foo"); Assert.assertTrue(reporter.isActive(info)); assertEquals(0, tags.get(Tags.SAMPLING_PRIORITY.getKey())); }