use of zipkin2.reporter.AsyncReporter in project spring-cloud-gcp by spring-cloud.
the class StackdriverTraceAutoConfiguration method stackdriverReporter.
@Bean(REPORTER_BEAN_NAME)
@ConditionalOnMissingBean(name = REPORTER_BEAN_NAME)
public Reporter<Span> stackdriverReporter(ReporterMetrics reporterMetrics, GcpTraceProperties trace, @Qualifier(SENDER_BEAN_NAME) Sender sender) {
AsyncReporter<Span> asyncReporter = AsyncReporter.builder(sender).queuedMaxSpans(1000).messageTimeout(trace.getMessageTimeout(), TimeUnit.SECONDS).metrics(reporterMetrics).build(StackdriverEncoder.V2);
CheckResult checkResult = asyncReporter.check();
if (!checkResult.ok()) {
LOGGER.warn("Error when performing Stackdriver AsyncReporter health check.", checkResult.error());
}
return asyncReporter;
}
use of zipkin2.reporter.AsyncReporter in project spring-cloud-gcp by spring-cloud.
the class StackdriverTraceAutoConfigurationTests method testAsyncReporterHealthCheck.
@Test
public void testAsyncReporterHealthCheck() {
Sender senderMock = mock(Sender.class);
when(senderMock.check()).thenReturn(CheckResult.OK);
when(senderMock.encoding()).thenReturn(SpanBytesEncoder.PROTO3.encoding());
this.contextRunner.withBean(StackdriverTraceAutoConfiguration.SENDER_BEAN_NAME, Sender.class, () -> senderMock).run(context -> {
Reporter<Span> asyncReporter = context.getBean(Reporter.class);
assertThat(asyncReporter).isNotNull();
verify(senderMock, times(1)).check();
});
}
Aggregations